svnno****@sourc*****
svnno****@sourc*****
2008年 11月 18日 (火) 23:09:37 JST
Revision: 2168 http://svn.sourceforge.jp/view?root=jiemamy&view=rev&rev=2168 Author: daisuke_m Date: 2008-11-18 23:09:36 +0900 (Tue, 18 Nov 2008) Log Message: ----------- cloneまわりのテストがコケてた。 Modified Paths: -------------- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/AbstractModel.java artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/RootModelImpl.java artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/core/model/node/TableModelImplTest.java zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/model/JiemamyModel.java zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/model/RootModel.java -------------- next part -------------- Modified: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/AbstractModel.java =================================================================== --- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/AbstractModel.java 2008-11-17 17:02:04 UTC (rev 2167) +++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/AbstractModel.java 2008-11-18 14:09:36 UTC (rev 2168) @@ -39,7 +39,7 @@ public abstract class AbstractModel implements JiemamyModel, JiemamyModelAccessor { /** - * TODO for Keisuke.K + * TODO for daisuke * @param <T> * @param obj * @return @@ -92,6 +92,18 @@ /** * {@inheritDoc} */ + @SuppressWarnings("unchecked") + public <T extends JiemamyModel>T clone() { + try { + return copyTo((T) super.clone()); + } catch (CloneNotSupportedException e) { + throw new JiemamyRuntimeException(e); + } + } + + /** + * {@inheritDoc} + */ public void dispose() { ModelIdManager modelIdManager = ModelIdManager.getInstance(); modelIdManager.unregister(this); Modified: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/RootModelImpl.java =================================================================== --- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/RootModelImpl.java 2008-11-17 17:02:04 UTC (rev 2167) +++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/RootModelImpl.java 2008-11-18 14:09:36 UTC (rev 2168) @@ -34,7 +34,6 @@ import org.jiemamy.spec.accessor.RootModelAccessor; import org.jiemamy.spec.exception.CannotAppendException; import org.jiemamy.spec.exception.CannotRemoveException; -import org.jiemamy.spec.exception.JiemamyRuntimeException; import org.jiemamy.spec.exception.TooManyElementsException; import org.jiemamy.spec.extension.dialect.Dialect; import org.jiemamy.spec.extension.dialect.IdentifierValidator; @@ -113,18 +112,6 @@ /** * {@inheritDoc} */ - @Override - public RootModel clone() { - try { - return copyTo((RootModel) super.clone()); - } catch (CloneNotSupportedException e) { - throw new JiemamyRuntimeException(e); - } - } - - /** - * {@inheritDoc} - */ @SuppressWarnings("unchecked") public <T extends JiemamyModel>T createJiemamyModel(Class<T> clazz) { return JiemamyModelFactory.create(this, clazz); Modified: artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/core/model/node/TableModelImplTest.java =================================================================== --- artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/core/model/node/TableModelImplTest.java 2008-11-17 17:02:04 UTC (rev 2167) +++ artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/core/model/node/TableModelImplTest.java 2008-11-18 14:09:36 UTC (rev 2168) @@ -257,24 +257,25 @@ RootModel cloneRoot = rootModel.clone(); TableModel cloneTable = (TableModel) cloneRoot.getNodes().get(0); + // オリジナルとクローンで、カラム数は同じ assertThat(tableModel.getColumns().size(), is(1)); assertThat(cloneTable.getColumns().size(), is(1)); tableModel.appendModel(column2); + // オリジナルに2つのモデルがセットされている + assertTrue(tableModel.getColumns().get(0) == column1); + assertTrue(tableModel.getColumns().get(1) == column2); + + // 追加分はクローンに影響しない assertThat(tableModel.getColumns().size(), is(2)); assertThat(cloneTable.getColumns().size(), is(1)); - assertTrue(tableModel.getColumns().get(0) == column1); - assertTrue(tableModel.getColumns().get(1) == column2); - - // IDは同一 + // TableとカラムのIDは同一 assertThat(tableModel.getId(), is(cloneTable.getId())); - assertThat(tableModel.getColumns().get(0).getId(), is(column1.getId())); - assertThat(tableModel.getColumns().get(1).getId(), is(column2.getId())); assertThat(tableModel.getColumns().get(0).getId(), is(cloneTable.getColumns().get(0).getId())); - // インスタンスは別 + // Tableとカラムのインスタンスは別 assertTrue(tableModel != cloneTable); assertTrue(tableModel.getColumns().get(0) != cloneTable.getColumns().get(0)); } Modified: zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/model/JiemamyModel.java =================================================================== --- zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/model/JiemamyModel.java 2008-11-17 17:02:04 UTC (rev 2167) +++ zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/model/JiemamyModel.java 2008-11-18 14:09:36 UTC (rev 2168) @@ -52,6 +52,13 @@ void appendModel(JiemamyModel jiemamyModel); /** + * TODO for daisuke + * @param <T> + * @return クローニングされたモデルのインスタンス + */ + <T extends JiemamyModel>T clone(); + + /** * このオブジェクトが保持しているリソースを破棄する。 */ void dispose(); Modified: zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/model/RootModel.java =================================================================== --- zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/model/RootModel.java 2008-11-17 17:02:04 UTC (rev 2167) +++ zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/model/RootModel.java 2008-11-18 14:09:36 UTC (rev 2168) @@ -40,12 +40,6 @@ public interface RootModel extends JiemamyModel { /** - * TODO for daisuke - * @return クローニングされたインスタンス - */ - RootModel clone(); - - /** * 新規に、この {@link RootModel}に従属しうるモデルインスタンスを生成する。 * * <p>引数として、未知の {@link JiemamyModel} 型クラスを与えた場合、 <code>null</code>を返してもよい(MAY)。</p>