svnno****@sourc*****
svnno****@sourc*****
2009年 4月 6日 (月) 20:21:37 JST
Revision: 3137 http://svn.sourceforge.jp/view?root=jiemamy&view=rev&rev=3137 Author: daisuke_m Date: 2009-04-06 20:21:37 +0900 (Mon, 06 Apr 2009) Log Message: ----------- refactor Modified Paths: -------------- artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/DatabaseTest.java artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/internal/test/TestModelsTestBase.java artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/composer/exporter/SqlExporterTest.java artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/dialect/DefaultSqlEmitterTest.java artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/internal/test/TestModelsTestBase.java artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/model/AttributeUtilTest.java Added Paths: ----------- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/test/TestModelBuilders.java Removed Paths: ------------- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/test/TestModelBuilderProvider.java -------------- next part -------------- Modified: artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/DatabaseTest.java =================================================================== --- artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/DatabaseTest.java 2009-04-06 11:19:59 UTC (rev 3136) +++ artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/DatabaseTest.java 2009-04-06 11:21:37 UTC (rev 3137) @@ -33,7 +33,7 @@ import org.jiemamy.composer.exporter.DefaultSqlExportConfig; import org.jiemamy.dialect.Dialect; -import org.jiemamy.internal.test.TestModelEntry; +import org.jiemamy.internal.test.TestModelBuilders; import org.jiemamy.internal.test.TestModelsTestBase; import org.jiemamy.model.RootModel; import org.jiemamy.model.sql.SqlStatement; @@ -53,7 +53,7 @@ @Override - public void doTest(TestModelEntry entry) throws Exception { + public void doTest(TestModelBuilders entry) throws Exception { Jiemamy jiemamy = entry.getBuiltModel(); for (TestDatabaseInstance db : TestDatabaseInstance.values()) { Modified: artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/internal/test/TestModelsTestBase.java =================================================================== --- artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/internal/test/TestModelsTestBase.java 2009-04-06 11:19:59 UTC (rev 3136) +++ artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/internal/test/TestModelsTestBase.java 2009-04-06 11:21:37 UTC (rev 3137) @@ -18,8 +18,6 @@ */ package org.jiemamy.internal.test; -import org.junit.After; -import org.junit.Before; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -33,8 +31,6 @@ private static Logger logger = LoggerFactory.getLogger(TestModelsTestBase.class); - private TestModelBuilderProvider provider; - /** * テストを行う。 @@ -42,37 +38,17 @@ * @param entry テストモデルのエントリ * @throws Exception 例外が発生した場合 */ - public abstract void doTest(TestModelEntry entry) throws Exception; + public abstract void doTest(TestModelBuilders entry) throws Exception; /** - * テストを初期化する。 - * - * @throws Exception 例外が発生した場合 - */ - @Before - public void setUp() throws Exception { - provider = new TestModelBuilderProvider(); - } - - /** - * テストの情報を破棄する。 - * - * @throws Exception 例外が発生した場合 - */ - @After - public void tearDown() throws Exception { - provider = null; - } - - /** * 全ての {@link TestModelBuilder}でテストを行うテストメソッド。 * * @throws Exception 例外が発生した場合 */ @Test public void testAllEntries() throws Exception { - for (TestModelEntry entry : provider) { - logger.info("==== Test Model: " + entry.getName()); + for (TestModelBuilders entry : TestModelBuilders.values()) { + logger.info("==== Test Model: " + entry.name()); doTest(entry); } } Deleted: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/test/TestModelBuilderProvider.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/test/TestModelBuilderProvider.java 2009-04-06 11:19:59 UTC (rev 3136) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/test/TestModelBuilderProvider.java 2009-04-06 11:21:37 UTC (rev 3137) @@ -1,65 +0,0 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2009/04/04 - * - * 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.internal.test; - -import java.io.IOException; -import java.io.InputStream; -import java.util.Iterator; -import java.util.List; - -import org.apache.commons.io.IOUtils; -import org.apache.commons.lang.CharEncoding; - -import org.jiemamy.Artemis; -import org.jiemamy.Jiemamy; -import org.jiemamy.utils.CollectionsUtil; - -/** - * テスト用モデルの構築を行うビルダを供給するプロバイダ。 - * - * @author daisuke - */ -public class TestModelBuilderProvider implements Iterable<TestModelEntry> { - - private List<TestModelEntry> entries = CollectionsUtil.newArrayList(); - - - /** - * インスタンスを生成する。 - * - * @throws IOException 入出力エラーが発生した場合 - */ - public TestModelBuilderProvider() throws IOException { - entries.add(new TestModelEntry("EMP-DEPT", new CoreTestModelBuilder(newJiemamy()), getXml("/sample.xml"))); - entries.add(new TestModelEntry("ORDER", new CoreTestModelBuilder2(newJiemamy()), getXml("/sample.xml"))); - } - - public Iterator<TestModelEntry> iterator() { - return entries.iterator(); - } - - private String getXml(String path) throws IOException { - InputStream in = TestModelBuilderProvider.class.getResourceAsStream(path); - return IOUtils.toString(in, CharEncoding.UTF_8); - } - - private Jiemamy newJiemamy() { - return Jiemamy.newInstance(new Artemis(), new ReflectionDialectProvider()); - } -} Copied: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/test/TestModelBuilders.java (from rev 3135, artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/test/TestModelBuilderProvider.java) =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/test/TestModelBuilders.java (rev 0) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/test/TestModelBuilders.java 2009-04-06 11:21:37 UTC (rev 3137) @@ -0,0 +1,78 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/04/04 + * + * 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.internal.test; + +import java.io.InputStream; + +import org.apache.commons.io.IOUtils; +import org.apache.commons.lang.CharEncoding; + +import org.jiemamy.Artemis; +import org.jiemamy.Jiemamy; +import org.jiemamy.exception.UnexpectedConditionError; + +/** + * テスト用モデルの構築を行うビルダを供給するプロバイダ。 + * + * @author daisuke + */ +public enum TestModelBuilders { + + /** */ + EMP_DEPT(new CoreTestModelBuilder(newJiemamy()), getXml("/sample.xml")), + + /** */ + ORDER(new CoreTestModelBuilder2(newJiemamy()), getXml("/sample.xml")); + + private static String getXml(String path) { + InputStream in = TestModelBuilders.class.getResourceAsStream(path); + String xml; + try { + xml = IOUtils.toString(in, CharEncoding.UTF_8); + } catch (Exception e) { + throw new UnexpectedConditionError("リソースにアクセスできない", e); + } + return xml; + } + + private static Jiemamy newJiemamy() { + return Jiemamy.newInstance(new Artemis(), new ReflectionDialectProvider()); + } + + + private final TestModelBuilder builder; + + private final String xml; + + + TestModelBuilders(TestModelBuilder builder, String xml) { + this.builder = builder; + this.xml = xml; + } + + /** + * TODO for daisuke + * + * @return + */ + public Jiemamy getBuiltModel() { + return builder.build(); + } + +} Property changes on: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/test/TestModelBuilders.java ___________________________________________________________________ Added: svn:mime-type + text/plain Modified: artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/composer/exporter/SqlExporterTest.java =================================================================== --- artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/composer/exporter/SqlExporterTest.java 2009-04-06 11:19:59 UTC (rev 3136) +++ artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/composer/exporter/SqlExporterTest.java 2009-04-06 11:21:37 UTC (rev 3137) @@ -33,7 +33,7 @@ import org.jiemamy.Jiemamy; import org.jiemamy.JiemamyFactory; import org.jiemamy.composer.Exporter; -import org.jiemamy.internal.test.TestModelEntry; +import org.jiemamy.internal.test.TestModelBuilders; import org.jiemamy.internal.test.TestModelsTestBase; import org.jiemamy.model.RootModel; @@ -58,7 +58,7 @@ * @throws Exception 例外が発生した場合 */ @Override - public void doTest(TestModelEntry entry) throws Exception { + public void doTest(TestModelBuilders entry) throws Exception { Jiemamy jiemamy = entry.getBuiltModel(); JiemamyFactory factory = jiemamy.getFactory(); Modified: artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/dialect/DefaultSqlEmitterTest.java =================================================================== --- artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/dialect/DefaultSqlEmitterTest.java 2009-04-06 11:19:59 UTC (rev 3136) +++ artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/dialect/DefaultSqlEmitterTest.java 2009-04-06 11:21:37 UTC (rev 3137) @@ -27,7 +27,7 @@ import org.jiemamy.dialect.internal.SqlEmitter; import org.jiemamy.dialect.internal.impl.DefaultDataTypeResolver; import org.jiemamy.dialect.internal.impl.DefaultSqlEmitter; -import org.jiemamy.internal.test.TestModelEntry; +import org.jiemamy.internal.test.TestModelBuilders; import org.jiemamy.internal.test.TestModelsTestBase; import org.jiemamy.model.sql.SqlStatement; import org.jiemamy.utils.model.RootModelUtil; @@ -48,7 +48,7 @@ * @throws Exception 例外が発生した場合 */ @Override - public void doTest(TestModelEntry entry) throws Exception { + public void doTest(TestModelBuilders entry) throws Exception { Jiemamy jiemamy = entry.getBuiltModel(); Dialect dialect = RootModelUtil.getDialect(jiemamy.getFactory().getRootModel()); SqlEmitter sqlEmitter = new DefaultSqlEmitter(new DefaultDataTypeResolver(dialect.getMoldManager())); Modified: artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/internal/test/TestModelsTestBase.java =================================================================== --- artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/internal/test/TestModelsTestBase.java 2009-04-06 11:19:59 UTC (rev 3136) +++ artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/internal/test/TestModelsTestBase.java 2009-04-06 11:21:37 UTC (rev 3137) @@ -18,8 +18,6 @@ */ package org.jiemamy.internal.test; -import org.junit.After; -import org.junit.Before; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -33,8 +31,6 @@ private static Logger logger = LoggerFactory.getLogger(TestModelsTestBase.class); - private TestModelBuilderProvider provider; - /** * テストを行う。 @@ -42,37 +38,17 @@ * @param entry テストモデルのエントリ * @throws Exception 例外が発生した場合 */ - public abstract void doTest(TestModelEntry entry) throws Exception; + public abstract void doTest(TestModelBuilders entry) throws Exception; /** - * テストを初期化する。 - * - * @throws Exception 例外が発生した場合 - */ - @Before - public void setUp() throws Exception { - provider = new TestModelBuilderProvider(); - } - - /** - * テストの情報を破棄する。 - * - * @throws Exception 例外が発生した場合 - */ - @After - public void tearDown() throws Exception { - provider = null; - } - - /** * 全ての {@link TestModelBuilder}でテストを行うテストメソッド。 * * @throws Exception 例外が発生した場合 */ @Test public void testAllEntries() throws Exception { - for (TestModelEntry entry : provider) { - logger.info("==== Test Model: " + entry.getName()); + for (TestModelBuilders entry : TestModelBuilders.values()) { + logger.info("==== Test Model: " + entry.name()); doTest(entry); } } Modified: artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/model/AttributeUtilTest.java =================================================================== --- artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/model/AttributeUtilTest.java 2009-04-06 11:19:59 UTC (rev 3136) +++ artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/model/AttributeUtilTest.java 2009-04-06 11:21:37 UTC (rev 3137) @@ -25,7 +25,7 @@ import java.util.SortedSet; import org.jiemamy.Jiemamy; -import org.jiemamy.internal.test.TestModelEntry; +import org.jiemamy.internal.test.TestModelBuilders; import org.jiemamy.internal.test.TestModelsTestBase; import org.jiemamy.model.RootModel; import org.jiemamy.model.attribute.AttributeModel; @@ -45,7 +45,7 @@ * @throws Exception 例外が発生した場合 */ @Override - public void doTest(TestModelEntry entry) throws Exception { + public void doTest(TestModelBuilders entry) throws Exception { Jiemamy jiemamy = entry.getBuiltModel(); RootModel rootModel = jiemamy.getFactory().getRootModel(); SortedSet<EntityModel> entities = rootModel.getEntities();