[Jiemamy-notify] commit [1927] [CORE-55] の際に移動し忘れたTestCaseを移動。

アーカイブの一覧に戻る

svnno****@sourc***** svnno****@sourc*****
2008年 9月 17日 (水) 22:52:55 JST


Revision: 1927
          http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=jiemamy&view=rev&rev=1927
Author:   shin1
Date:     2008-09-17 22:52:54 +0900 (Wed, 17 Sep 2008)

Log Message:
-----------
[CORE-55]の際に移動し忘れたTestCaseを移動。
META-INF内のExportedPackagesがclassの移動に追随されていなかったので、修正。

Modified Paths:
--------------
    artemis/trunk/org.jiemamy.core/META-INF/MANIFEST.MF
    artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/core/model/node/TableModelTest.java

Added Paths:
-----------
    artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/core/event/collectionimpl/
    artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/core/event/collectionimpl/ObservableListTest.java
    artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/core/event/collectionimpl/ObservableMapTest.java

Removed Paths:
-------------
    artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/core/utils/collectionimpl/


-------------- next part --------------
Modified: artemis/trunk/org.jiemamy.core/META-INF/MANIFEST.MF
===================================================================
--- artemis/trunk/org.jiemamy.core/META-INF/MANIFEST.MF	2008-09-16 16:52:28 UTC (rev 1926)
+++ artemis/trunk/org.jiemamy.core/META-INF/MANIFEST.MF	2008-09-17 13:52:54 UTC (rev 1927)
@@ -248,6 +248,7 @@
  org.jiemamy.core,
  org.jiemamy.core.adapter,
  org.jiemamy.core.event,
+ org.jiemamy.core.event.collectionimpl,
  org.jiemamy.core.event.model,
  org.jiemamy.core.exception,
  org.jiemamy.core.extension.dialect,
@@ -272,7 +273,6 @@
  org.jiemamy.core.model.typedef.datatype.adapter,
  org.jiemamy.core.model.typedef.datatype.impl,
  org.jiemamy.core.utils,
- org.jiemamy.core.utils.collectionimpl,
  org.jiemamy.core.utils.processor,
  org.jiemamy.core.utils.processor.base,
  org.jiemamy.core.utils.processor.connection,

Copied: artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/core/event/collectionimpl/ObservableListTest.java (from rev 1926, artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/core/utils/collectionimpl/ObservableListTest.java)
===================================================================
--- artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/core/event/collectionimpl/ObservableListTest.java	                        (rev 0)
+++ artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/core/event/collectionimpl/ObservableListTest.java	2008-09-17 13:52:54 UTC (rev 1927)
@@ -0,0 +1,296 @@
+/*
+ * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others.
+ * Created on 2008/06/29
+ *
+ * This file is part of Jiemamy.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific language
+ * governing permissions and limitations under the License.
+ */
+package org.jiemamy.core.event.collectionimpl;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.seasar.framework.container.S2Container;
+import org.seasar.framework.container.factory.S2ContainerFactory;
+
+import org.jiemamy.core.event.ObservableCollectionChangeEvent;
+import org.jiemamy.core.event.ObservableCollectionChangeListener;
+import org.jiemamy.core.event.ObservableCollectionChangeEvent.Timing;
+import org.jiemamy.core.event.collectionimpl.ObservableList;
+import org.jiemamy.core.model.typedef.ColumnModel;
+import org.jiemamy.core.model.typedef.datatype.DataType;
+import org.jiemamy.core.model.typedef.datatype.impl.IntegerDataTypeMock;
+import org.jiemamy.core.model.typedef.datatype.impl.TimestampDataTypeMock;
+import org.jiemamy.core.model.typedef.datatype.impl.VarcharDataTypeMock;
+
+/**
+ * {@link ObservableList}のテストクラス。
+ * @author shin1ogawa
+ */
+public class ObservableListTest {
+	
+	static S2Container s2container;
+	
+
+	/**
+	 * Test用のColumnModelを複数作成する。
+	 * @param s2container 
+	 * @return Test用のColumnModelの配列
+	 */
+	public static ColumnModel[] newTestColumnModels(S2Container s2container) {
+		Object[][] columnDatas = {
+			{
+				"ID",
+				new IntegerDataTypeMock()
+			},
+			{
+				"NAME",
+				new VarcharDataTypeMock(100)
+			},
+			{
+				"TIMESTAMP",
+				new TimestampDataTypeMock()
+			}
+		};
+		ColumnModel[] columnModels = new ColumnModel[columnDatas.length];
+		for (int i = 0; i < columnModels.length; i++) {
+			columnModels[i] = (ColumnModel) s2container.getComponent(ColumnModel.class);
+			columnModels[i].setName((String) columnDatas[i][0]);
+			columnModels[i].setDataType((DataType) columnDatas[i][1]);
+		}
+		return columnModels;
+	}
+	
+	/**
+	 * S2Containerを作成する。
+	 */
+	@BeforeClass
+	public static void setUpBeforeClass() {
+		s2container = S2ContainerFactory.create("jiemamy-core.dicon");
+	}
+	
+
+	ObservableList<ColumnModel> modelList;
+	
+	ModelCollectionChangeListenerImpl listener;
+	
+
+	/**
+	 * {@link ObservableList}から発火された{@link ObservableCollectionChangeEvent}から、
+	 * 対象のcollectionを取得し、それの要素に対して操作をしてもEventが発火される必要がある。
+	 * このTestは全ての変更系メソッドに対して行うのが理想的。
+	 */
+	@Test
+	public void collectionChangeEventから取得したListに対する操作でもEventが発火されるべき() {
+		test_addAll();
+		List<ColumnModel> collection = listener.events.get(0).getCollection();
+		System.out.println(collection.getClass());
+		listener.events.clear();
+		collection.clear();
+		assertTrue(listener.events.size() > 0);
+	}
+	
+	/**
+	 * {@link #modelList}を生成する。
+	 */
+	@Before
+	public void setUp() {
+		modelList = ObservableList.decorate(new ArrayList<ColumnModel>());
+		listener = new ModelCollectionChangeListenerImpl();
+		modelList.addListener(listener);
+	}
+	
+	/**
+	 * {@link #modelList}を破棄する。
+	 */
+	@After
+	public void tearDown() {
+		modelList = null;
+	}
+	
+	/**
+	 * {@link ObservableList#add(Object)}のTest.
+	 */
+	@Test
+	public void test_add() {
+		ColumnModel[] columns = newTestColumnModels(s2container);
+		modelList.add(columns[0]);
+		assertEquals(1, modelList.size());
+		assertEquals(2, listener.events.size()); // BEFORE_ADD, AFTER_ADD
+		assertEquals(Timing.BEFORE_ADD, listener.events.get(0).getTiming());
+		assertEquals(Timing.AFTER_ADD, listener.events.get(1).getTiming());
+		columns[0].setLogicalName("aaa");
+		assertEquals(3, listener.events.size()); // COLLECTION_CHANGED
+		assertEquals(Timing.COLLECTION_CHANGED, listener.events.get(2).getTiming());
+		listener.events.clear();
+		
+		modelList.add(columns[1]);
+		modelList.add(columns[2]);
+		assertEquals(4, listener.events.size()); // (BEFORE_ADD, AFTER_ADD) * 2
+		assertArrayEquals(columns, modelList.toArray());
+	}
+	
+	/**
+	 * {@link ObservableList#addAll(Collection)}のTest.
+	 */
+	@Test
+	public void test_addAll() {
+		ColumnModel[] columns = newTestColumnModels(s2container);
+		ArrayList<ColumnModel> columnList = new ArrayList<ColumnModel>();
+		for (ColumnModel column : columns) {
+			columnList.add(column);
+		}
+		modelList.addAll(columnList);
+		assertEquals(columns.length * 2, listener.events.size());
+		assertArrayEquals(columns, modelList.toArray());
+	}
+	
+	/**
+	 * {@link ObservableList#clear()}のTest.
+	 */
+	@Test
+	public void test_clear() {
+		ColumnModel[] columns = newTestColumnModels(s2container);
+		for (ColumnModel column : columns) {
+			modelList.add(column);
+		}
+		listener.events.clear();
+		// 
+		modelList.clear();
+		assertEquals(0, modelList.size());
+		assertEquals(columns.length * 2, listener.events.size());
+		assertEquals("要素の数分まとめてbeforeRemoveが発生する。", Timing.BEFORE_REMOVE, listener.events.get(0).getTiming());
+		assertEquals("要素の数分まとめてbeforeRemoveが発生する。", Timing.BEFORE_REMOVE, listener.events.get(1).getTiming());
+		assertEquals("要素の数分まとめてbeforeRemoveが発生する。", Timing.BEFORE_REMOVE, listener.events.get(2).getTiming());
+		assertEquals("要素の数分まとめてafterRemoveが発生する。", Timing.AFTER_REMOVE, listener.events.get(3).getTiming());
+		assertEquals("要素の数分まとめてafterRemoveが発生する。", Timing.AFTER_REMOVE, listener.events.get(4).getTiming());
+		assertEquals("要素の数分まとめてafterRemoveが発生する。", Timing.AFTER_REMOVE, listener.events.get(5).getTiming());
+		assertTrue(columns[0] == listener.events.get(0).getModel());
+		assertTrue(columns[1] == listener.events.get(1).getModel());
+		assertTrue(columns[2] == listener.events.get(2).getModel());
+		assertTrue(columns[0] == listener.events.get(3).getModel());
+		assertTrue(columns[1] == listener.events.get(4).getModel());
+		assertTrue(columns[2] == listener.events.get(5).getModel());
+	}
+	
+	/**
+	 * {@link ObservableList#addAll(int, Collection)}のTest.
+	 */
+	@Test
+	public void test_Index指定のaddAll() {
+		ColumnModel[] columns = newTestColumnModels(s2container);
+		ArrayList<ColumnModel> columnList = new ArrayList<ColumnModel>();
+		for (ColumnModel column : columns) {
+			columnList.add(column);
+		}
+		modelList.addAll(0, columnList);
+		assertEquals(columns.length * 2, listener.events.size());
+		assertArrayEquals(columns, modelList.toArray());
+		listener.events.clear();
+		
+		columns[2].setSimpleIndex(false);
+		assertEquals("ColumnModelの属性を変更すると、modelChangeが通知されるはず。", 1, listener.events.size());
+		assertEquals("ColumnModelの属性を変更すると、modelChangeが通知されるはず。", Timing.COLLECTION_CHANGED, listener.events.get(0)
+			.getTiming());
+	}
+	
+	/**
+	 * {@link ObservableList#remove(Object)}のTest.
+	 * {@link ObservableList#remove(int)}のTest.
+	 */
+	@Test
+	public void test_remove() {
+		ColumnModel[] columns = newTestColumnModels(s2container);
+		for (ColumnModel column : columns) {
+			modelList.add(column);
+		}
+		listener.events.clear();
+		
+		modelList.remove(columns[1]);
+		assertEquals("3つが2つに減っているはず。", 2, modelList.size());
+		assertEquals("BEFORE_REMOVE,beforeAddのふたつが通知されるはず。", 2, listener.events.size());
+		assertEquals("BEFORE_REMOVE,beforeAddのふたつが通知されるはず。", Timing.BEFORE_REMOVE, listener.events.get(0).getTiming());
+		assertEquals("BEFORE_REMOVE,beforeAddのふたつが通知されるはず。", Timing.AFTER_REMOVE, listener.events.get(1).getTiming());
+		assertEquals("削除対象となった要素のインスタンスは目的通りか。", columns[1], listener.events.get(0).getModel());
+		listener.events.clear();
+		
+		modelList.remove(1); // columns[2]
+		assertEquals("2つが1つに減っているはず。", 1, modelList.size());
+		assertEquals("BEFORE_REMOVE,beforeAddのふたつが通知されるはず。", 2, listener.events.size());
+		assertEquals("BEFORE_REMOVE,beforeAddのふたつが通知されるはず。", Timing.BEFORE_REMOVE, listener.events.get(0).getTiming());
+		assertEquals("BEFORE_REMOVE,beforeAddのふたつが通知されるはず。", Timing.AFTER_REMOVE, listener.events.get(1).getTiming());
+		assertEquals("削除対象となった要素のインスタンスは目的通りか。", columns[2], listener.events.get(0).getModel());
+		listener.events.clear();
+		
+		columns[0].setFreeString("free string");
+		assertEquals("Collectionに残っている要素に対する属性の変更のEventは通知される。", 1, listener.events.size());
+		listener.events.clear();
+		columns[1].setFreeString("free string");
+		columns[2].setFreeString("free string");
+		assertEquals("Collectionに残っていない要素に対する属性の変更のEventは通知されない。", 0, listener.events.size());
+	}
+	
+	/**
+	 * {@link ObservableList#removeAll(Collection)}のTest.
+	 */
+	@Test
+	public void test_removeAll() {
+		ColumnModel[] columns = newTestColumnModels(s2container);
+		ArrayList<ColumnModel> columnList = new ArrayList<ColumnModel>();
+		for (ColumnModel column : columns) {
+			columnList.add(column);
+		}
+		modelList.addAll(columnList);
+		listener.events.clear();
+		// ここから
+		List<ColumnModel> columnArray = new ArrayList<ColumnModel>();
+		columnArray.add(columns[0]);
+		columnArray.add(columns[2]);
+		modelList.removeAll(columnArray);
+		assertEquals(1, modelList.size());
+	}
+	
+
+	/**
+	 * 試験用の{@link ObservableCollectionChangeListener}の実装。
+	 * @author shin1ogawa
+	 */
+	class ModelCollectionChangeListenerImpl implements
+			ObservableCollectionChangeListener<List<ColumnModel>, ColumnModel> {
+		
+		List<ObservableCollectionChangeEvent<List<ColumnModel>, ColumnModel>> events;
+		
+		{
+			events = new ArrayList<ObservableCollectionChangeEvent<List<ColumnModel>, ColumnModel>>();
+		}
+		
+
+		/**
+		 * {@inheritDoc}
+		 */
+		public void collectionChanged(ObservableCollectionChangeEvent<List<ColumnModel>, ColumnModel> event) {
+			events.add(event);
+		}
+		
+	}
+}

Copied: artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/core/event/collectionimpl/ObservableMapTest.java (from rev 1926, artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/core/utils/collectionimpl/ObservableMapTest.java)
===================================================================
--- artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/core/event/collectionimpl/ObservableMapTest.java	                        (rev 0)
+++ artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/core/event/collectionimpl/ObservableMapTest.java	2008-09-17 13:52:54 UTC (rev 1927)
@@ -0,0 +1,250 @@
+/*
+ * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others.
+ * Created on 2008/07/06
+ *
+ * This file is part of Jiemamy.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific language
+ * governing permissions and limitations under the License.
+ */
+package org.jiemamy.core.event.collectionimpl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.seasar.framework.container.S2Container;
+import org.seasar.framework.container.factory.S2ContainerFactory;
+
+import org.jiemamy.core.event.ObservableCollectionChangeEvent;
+import org.jiemamy.core.event.ObservableCollectionChangeListener;
+import org.jiemamy.core.event.ObservableCollectionChangeEvent.Timing;
+import org.jiemamy.core.event.collectionimpl.ObservableMap;
+import org.jiemamy.core.model.typedef.ColumnModel;
+import org.jiemamy.core.model.typedef.datatype.DataType;
+import org.jiemamy.core.model.typedef.datatype.impl.IntegerDataTypeMock;
+import org.jiemamy.core.model.typedef.datatype.impl.TimestampDataTypeMock;
+import org.jiemamy.core.model.typedef.datatype.impl.VarcharDataTypeMock;
+
+/**
+ * {@link ObservableMap}のテストクラス。
+ * @author shin1
+ */
+public class ObservableMapTest {
+	
+	static S2Container s2container;
+	
+
+	/**
+	 * Test用のColumnModelを複数作成する。
+	 * @param s2container 
+	 * @return Test用のColumnModelの配列
+	 */
+	public static ColumnModel[] newTestColumnModels(S2Container s2container) {
+		Object[][] columnDatas = {
+			{
+				"ID",
+				new IntegerDataTypeMock()
+			},
+			{
+				"NAME",
+				new VarcharDataTypeMock(100)
+			},
+			{
+				"TIMESTAMP",
+				new TimestampDataTypeMock()
+			}
+		};
+		ColumnModel[] columnModels = new ColumnModel[columnDatas.length];
+		for (int i = 0; i < columnModels.length; i++) {
+			columnModels[i] = (ColumnModel) s2container.getComponent(ColumnModel.class);
+			columnModels[i].setName((String) columnDatas[i][0]);
+			columnModels[i].setDataType((DataType) columnDatas[i][1]);
+		}
+		return columnModels;
+	}
+	
+	/**
+	 * S2Containerを作成する。
+	 */
+	@BeforeClass
+	public static void setUpBeforeClass() {
+		s2container = S2ContainerFactory.create("jiemamy-core.dicon");
+	}
+	
+
+	ObservableMap<Integer, ColumnModel> modelMap;
+	
+	ModelCollectionChangeListenerImpl listener;
+	
+
+	/**
+	 * {@link #modelMap}を生成する。
+	 */
+	@Before
+	public void setUp() {
+		modelMap = ObservableMap.decorate(new HashMap<Integer, ColumnModel>());
+		listener = new ModelCollectionChangeListenerImpl();
+		modelMap.addListener(listener);
+	}
+	
+	/**
+	 * {@link #modelMap}を破棄する。
+	 */
+	@After
+	public void tearDown() {
+		modelMap = null;
+	}
+	
+	/**
+	 * {@link ObservableMap#clear()}のTest.
+	 */
+	@Test
+	public void test_clear() {
+		ColumnModel[] columns = newTestColumnModels(s2container);
+		int index = 0;
+		for (ColumnModel column : columns) {
+			modelMap.put(index++, column);
+		}
+		listener.events.clear();
+		// 
+		modelMap.clear();
+		assertEquals(0, modelMap.size());
+		assertEquals(columns.length * 2, listener.events.size());
+		assertEquals("要素の数分まとめてbeforeRemoveが発生する。", Timing.BEFORE_REMOVE, listener.events.get(0).getTiming());
+		assertEquals("要素の数分まとめてbeforeRemoveが発生する。", Timing.BEFORE_REMOVE, listener.events.get(1).getTiming());
+		assertEquals("要素の数分まとめてbeforeRemoveが発生する。", Timing.BEFORE_REMOVE, listener.events.get(2).getTiming());
+		assertEquals("要素の数分まとめてbeforeRemoveが発生する。", 0, listener.events.get(0).getIndex());
+		assertEquals("要素の数分まとめてbeforeRemoveが発生する。", 1, listener.events.get(1).getIndex());
+		assertEquals("要素の数分まとめてbeforeRemoveが発生する。", 2, listener.events.get(2).getIndex());
+		assertEquals("要素の数分まとめてafterRemoveが発生する。", Timing.AFTER_REMOVE, listener.events.get(3).getTiming());
+		assertEquals("要素の数分まとめてafterRemoveが発生する。", Timing.AFTER_REMOVE, listener.events.get(4).getTiming());
+		assertEquals("要素の数分まとめてafterRemoveが発生する。", Timing.AFTER_REMOVE, listener.events.get(5).getTiming());
+		assertEquals("要素の数分まとめてbeforeRemoveが発生する。", 0, listener.events.get(3).getIndex());
+		assertEquals("要素の数分まとめてbeforeRemoveが発生する。", 1, listener.events.get(4).getIndex());
+		assertEquals("要素の数分まとめてbeforeRemoveが発生する。", 2, listener.events.get(5).getIndex());
+	}
+	
+	/**
+	 * {@link ObservableMap#put(Object, Object)}のTest.
+	 */
+	@Test
+	public void test_put() {
+		ColumnModel[] columns = newTestColumnModels(s2container);
+		modelMap.put(0, columns[0]);
+		assertEquals(1, modelMap.size());
+		assertEquals(2, listener.events.size()); // BEFORE_ADD, AFTER_ADD
+		assertEquals(Timing.BEFORE_ADD, listener.events.get(0).getTiming());
+		assertEquals(Timing.AFTER_ADD, listener.events.get(1).getTiming());
+		columns[0].setLogicalName("aaa");
+		assertEquals(3, listener.events.size()); // COLLECTION_CHANGED
+		assertEquals(Timing.COLLECTION_CHANGED, listener.events.get(2).getTiming());
+		listener.events.clear();
+		
+		modelMap.put(1, columns[1]);
+		modelMap.put(2, columns[2]);
+		assertEquals(4, listener.events.size()); // (BEFORE_ADD, AFTER_ADD) * 2
+		assertTrue(columns[0] == modelMap.get(0));
+		assertTrue(columns[1] == modelMap.get(1));
+		assertTrue(columns[2] == modelMap.get(2));
+//		assertEquals(0, listener.events.get(0).getIndex());
+//		assertEquals(0, listener.events.get(1).getIndex());
+//		assertEquals(1, listener.events.get(2).getIndex());
+//		assertEquals(1, listener.events.get(3).getIndex());
+	}
+	
+	/**
+	 * {@link ObservableMap#putAll(Map)}のTest.
+	 */
+	@Test
+	public void test_putAll() {
+		ColumnModel[] columns = newTestColumnModels(s2container);
+		ObservableMap<Integer, ColumnModel> columnMap = new ObservableMap<Integer, ColumnModel>();
+		int index = 0;
+		for (ColumnModel column : columns) {
+			columnMap.put(index++, column);
+		}
+		modelMap.putAll(columnMap);
+		assertEquals(columns.length * 2, listener.events.size());
+		assertTrue(columns[0] == modelMap.get(0));
+		assertTrue(columns[1] == modelMap.get(1));
+		assertTrue(columns[2] == modelMap.get(2));
+	}
+	
+	/**
+	 * {@link ObservableMap#remove(Object)}のTest.
+	 */
+	@Test
+	public void test_remove() {
+		ColumnModel[] columns = newTestColumnModels(s2container);
+		int index = 0;
+		for (ColumnModel column : columns) {
+			modelMap.put(index++, column);
+		}
+		listener.events.clear();
+		
+		// intだとremove(key)でなくremove(index)として動作してしまうので、Integerとして処理する。
+		modelMap.remove(Integer.valueOf(1));
+		assertEquals("3つが2つに減っているはず。", 2, modelMap.size());
+		assertEquals("BEFORE_REMOVE,beforeAddのふたつが通知されるはず。", 2, listener.events.size());
+		assertEquals("BEFORE_REMOVE,beforeAddのふたつが通知されるはず。", Timing.BEFORE_REMOVE, listener.events.get(0).getTiming());
+		assertEquals("BEFORE_REMOVE,beforeAddのふたつが通知されるはず。", Timing.AFTER_REMOVE, listener.events.get(1).getTiming());
+		assertEquals("削除対象となった要素のインスタンスは目的通りか。", columns[1], listener.events.get(0).getModel());
+//		assertEquals("削除対象となった要素の要素番号は目的通りか。", 1, listener.events.get(0).getIndex());
+		listener.events.clear();
+		
+		modelMap.remove(Integer.valueOf(2)); // columns[2]
+		assertEquals("2つが1つに減っているはず。", 1, modelMap.size());
+		assertEquals("BEFORE_REMOVE,beforeAddのふたつが通知されるはず。", 2, listener.events.size());
+		assertEquals("BEFORE_REMOVE,beforeAddのふたつが通知されるはず。", Timing.BEFORE_REMOVE, listener.events.get(0).getTiming());
+		assertEquals("BEFORE_REMOVE,beforeAddのふたつが通知されるはず。", Timing.AFTER_REMOVE, listener.events.get(1).getTiming());
+//		assertEquals("削除対象となった要素のインスタンスは目的通りか。", columns[2], listener.events.get(0).getModel());
+		listener.events.clear();
+		
+		columns[0].setFreeString("free string");
+		assertEquals("Collectionに残っている要素に対する属性の変更のEventは通知される。", 1, listener.events.size());
+		listener.events.clear();
+		columns[1].setFreeString("free string");
+		columns[2].setFreeString("free string");
+		assertEquals("Collectionに残っていない要素に対する属性の変更のEventは通知されない。", 0, listener.events.size());
+	}
+	
+
+	/**
+	 * 試験用の{@link ObservableCollectionChangeListener}の実装。
+	 * @author shin1ogawa
+	 */
+	class ModelCollectionChangeListenerImpl implements
+			ObservableCollectionChangeListener<Map<Integer, ColumnModel>, ColumnModel> {
+		
+		List<ObservableCollectionChangeEvent<Map<Integer, ColumnModel>, ColumnModel>> events =
+				new ArrayList<ObservableCollectionChangeEvent<Map<Integer, ColumnModel>, ColumnModel>>();
+		
+
+		/**
+		 * {@inheritDoc}
+		 */
+		public void collectionChanged(ObservableCollectionChangeEvent<Map<Integer, ColumnModel>, ColumnModel> event) {
+			events.add(event);
+		}
+		
+	}
+	
+}


Property changes on: artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/core/event/collectionimpl/ObservableMapTest.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/core/model/node/TableModelTest.java
===================================================================
--- artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/core/model/node/TableModelTest.java	2008-09-16 16:52:28 UTC (rev 1926)
+++ artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/core/model/node/TableModelTest.java	2008-09-17 13:52:54 UTC (rev 1927)
@@ -31,12 +31,12 @@
 import org.jiemamy.core.event.ModelChangeEvent;
 import org.jiemamy.core.event.ObservableCollectionChangeEvent;
 import org.jiemamy.core.event.SetterInterceptor;
+import org.jiemamy.core.event.collectionimpl.ObservableListTest;
 import org.jiemamy.core.event.model.node.TableModelChangeListener;
 import org.jiemamy.core.model.RootModel;
 import org.jiemamy.core.model.node.index.IndexModel;
 import org.jiemamy.core.model.typedef.ColumnModel;
 import org.jiemamy.core.model.typedef.constraint.CheckConstraintModel;
-import org.jiemamy.core.utils.collectionimpl.ObservableListTest;
 import org.jiemamy.core.utils.debug.S2ContainerUtil;
 
 /**


Jiemamy-notify メーリングリストの案内
アーカイブの一覧に戻る