svnno****@sourc*****
svnno****@sourc*****
2009年 2月 24日 (火) 19:59:15 JST
Revision: 2724 http://svn.sourceforge.jp/view?root=jiemamy&view=rev&rev=2724 Author: daisuke_m Date: 2009-02-24 19:59:15 +0900 (Tue, 24 Feb 2009) Log Message: ----------- Column, Entity名にnull設定しようとした場合、例外を飛ばす仕様に変更。 / DatabaseImporterTestを一時凍結。 Modified Paths: -------------- artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/FileCommentTest.java artemis/trunk/jiemamy-composer/pom.xml artemis/trunk/jiemamy-composer/src/test/java/org/jiemamy/composer/importer/DatabaseImporterTest.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/attribute/ColumnModelImpl.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/entity/AbstractEntityModel.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/entity/ViewModelImpl.java zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/attribute/AttributeModel.java zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/entity/EntityModel.java zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/entity/ViewModel.java Added Paths: ----------- artemis/trunk/jiemamy-composer/src/test/resources/h2-1.1.102.jar artemis/trunk/jiemamy-composer/src/test/resources/h2.sql -------------- next part -------------- Modified: artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/FileCommentTest.java =================================================================== --- artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/FileCommentTest.java 2009-02-24 01:27:03 UTC (rev 2723) +++ artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/FileCommentTest.java 2009-02-24 10:59:15 UTC (rev 2724) @@ -122,12 +122,16 @@ test(new File(file + "/src"), errFiles); logger.info("End Project " + path); } - logger.info("==== FAILURE ============"); + StringBuilder sb = new StringBuilder(); - for (File file : errFiles) { - logger.info(file.toString()); - sb.append(file.toString()).append(SystemUtils.LINE_SEPARATOR); + if (errFiles.size() > 0) { + logger.info("==== FAILURE ============"); + for (File file : errFiles) { + logger.info(file.toString()); + sb.append(file.toString()).append(SystemUtils.LINE_SEPARATOR); + } } + assertThat(sb.toString(), errFiles.size(), is(0)); } Modified: artemis/trunk/jiemamy-composer/pom.xml =================================================================== --- artemis/trunk/jiemamy-composer/pom.xml 2009-02-24 01:27:03 UTC (rev 2723) +++ artemis/trunk/jiemamy-composer/pom.xml 2009-02-24 10:59:15 UTC (rev 2724) @@ -53,13 +53,24 @@ <version>0.94</version> <scope>test</scope> </dependency> + <dependency> + <groupId>com.h2database</groupId> + <artifactId>h2</artifactId> + <version>1.1.102</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>servlet-api</artifactId> + <version>2.4</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.osgi</groupId> + <artifactId>osgi_R4_core</artifactId> + <version>1.0</version> + </dependency> <dependency> - <groupId>com.h2database</groupId> - <artifactId>h2</artifactId> - <version>1.1.102</version> - <scope>test</scope> - </dependency> - <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>1.5.5</version> Modified: artemis/trunk/jiemamy-composer/src/test/java/org/jiemamy/composer/importer/DatabaseImporterTest.java =================================================================== --- artemis/trunk/jiemamy-composer/src/test/java/org/jiemamy/composer/importer/DatabaseImporterTest.java 2009-02-24 01:27:03 UTC (rev 2723) +++ artemis/trunk/jiemamy-composer/src/test/java/org/jiemamy/composer/importer/DatabaseImporterTest.java 2009-02-24 10:59:15 UTC (rev 2724) @@ -33,6 +33,7 @@ import org.junit.After; import org.junit.Before; +import org.junit.Ignore; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -99,9 +100,11 @@ jiemamy = Jiemamy.newInstance(new Artemis(), new ReflectionDialectProvider()); factory = jiemamy.getFactory(); rootModel = factory.getRootModel(); - rootModel.setDialectClassName("org.jiemamy.dialect.postgresql.PostgresqlDialect"); + rootModel.setDialectClassName("org.jiemamy.dialect.h2.H2Dialect"); dialect = jiemamy.getDialect(rootModel); + + Class.forName("org.h2.Driver"); } /** @@ -122,6 +125,7 @@ * @throws Exception */ @Test + @Ignore("H2Dialectが無いとテストできない") public void test01_DBからのインポートテスト() throws Exception { ImportContext ctx = createContext(); logger.info("START import..."); @@ -132,10 +136,10 @@ assertThat(rootModel.getEntities().size(), is(4)); assertThat(RootModelUtil.getAllForeignKeys(rootModel).size(), is(5)); - TableModel pollTable = RootModelUtil.getEntity(rootModel, TableModel.class, "t_poll"); + TableModel pollTable = RootModelUtil.getEntity(rootModel, TableModel.class, "T_POLL"); logger.info("Table - " + pollTable.getName()); - assertThat(pollTable.getName(), is("t_poll")); + assertThat(pollTable.getName(), is("T_POLL")); assertThat(TableUtil.getColumns(pollTable).size(), is(11)); List<UUID> pkColumnIds = CollectionsUtil.newArrayList(); @@ -147,7 +151,7 @@ logger.info(" Column - " + column1.getName()); BuiltinDataType builtinDataType1 = DataTypeUtil.toBuiltinDataType(column1.getDataType(), jiemamy.getReferenceResolver()); - assertThat(column1.getName(), is("poll_id")); + assertThat(column1.getName(), is("POLL_ID")); assertThat(builtinDataType1.getCategory(), is(DataTypeCategory.INTEGER)); assertThat(builtinDataType1.getTypeName(), is("serial")); // FIXME この仕様はまだ未実装 @@ -158,7 +162,7 @@ logger.info(" Column - " + column2.getName()); BuiltinDataType builtinDataType2 = DataTypeUtil.toBuiltinDataType(column2.getDataType(), jiemamy.getReferenceResolver()); - assertThat(column2.getName(), is("title")); + assertThat(column2.getName(), is("TITLE")); assertThat(builtinDataType2.getCategory(), is(DataTypeCategory.VARCHAR)); assertThat(builtinDataType2.getTypeName(), is("varchar")); assertThat(builtinDataType2.getAdapter(SizedDataTypeAdapter.class).getSize(), is(128)); @@ -204,25 +208,8 @@ ctx.setValue(DatabaseImporter.DIALECT, dialect); ctx.setValue(DatabaseImporter.DATABASE_NAME, "jpoll"); ctx.setValue(DatabaseImporter.DRIVER_JAR_PATH, new URL[] { - new File("./src/test/resources/postgresql-8.3-603.jdbc3.jar").toURL() + new File("./src/test/resources/h2-1.1.102.jar").toURL() }); - ctx.setValue(DatabaseImporter.DRIVER_CLASS_NAME, "org.postgresql.Driver"); - ctx.setValue(DatabaseImporter.URI, "jdbc:postgresql://localhost/jpoll"); - ctx.setValue(DatabaseImporter.SCHEMA, ""); - ctx.setValue(DatabaseImporter.USERNAME, "postgres"); - ctx.setValue(DatabaseImporter.PASSWORD, "postgres"); - ctx.setValue(DatabaseImporter.SELECTED_ENTITIES, null); - ctx.setValue(DatabaseImporter.ENTITY_TYPES, null); - return ctx; - } - - private ImportContext createContext2() throws MalformedURLException { - ImportContext ctx = new ImportContextImpl(); - ctx.setValue(DatabaseImporter.DIALECT, dialect); - ctx.setValue(DatabaseImporter.DATABASE_NAME, "jpoll"); - ctx.setValue(DatabaseImporter.DRIVER_JAR_PATH, new URL[] { - new File("./lib/h2-1.1.102.jar").toURL() - }); ctx.setValue(DatabaseImporter.DRIVER_CLASS_NAME, "org.h2.Driver"); ctx.setValue(DatabaseImporter.URI, "jdbc:h2:./src/test/resources/database/testdb"); ctx.setValue(DatabaseImporter.SCHEMA, ""); @@ -233,4 +220,20 @@ return ctx; } +// private ImportContext createContext() throws MalformedURLException { +// ImportContext ctx = new ImportContextImpl(); +// ctx.setValue(DatabaseImporter.DIALECT, dialect); +// ctx.setValue(DatabaseImporter.DATABASE_NAME, "jpoll"); +// ctx.setValue(DatabaseImporter.DRIVER_JAR_PATH, new URL[] { +// new File("./src/test/resources/postgresql-8.3-603.jdbc3.jar").toURL() +// }); +// ctx.setValue(DatabaseImporter.DRIVER_CLASS_NAME, "org.postgresql.Driver"); +// ctx.setValue(DatabaseImporter.URI, "jdbc:postgresql://localhost/jpoll"); +// ctx.setValue(DatabaseImporter.SCHEMA, ""); +// ctx.setValue(DatabaseImporter.USERNAME, "postgres"); +// ctx.setValue(DatabaseImporter.PASSWORD, "postgres"); +// ctx.setValue(DatabaseImporter.SELECTED_ENTITIES, null); +// ctx.setValue(DatabaseImporter.ENTITY_TYPES, null); +// return ctx; +// } } Added: artemis/trunk/jiemamy-composer/src/test/resources/h2-1.1.102.jar =================================================================== (Binary files differ) Property changes on: artemis/trunk/jiemamy-composer/src/test/resources/h2-1.1.102.jar ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: artemis/trunk/jiemamy-composer/src/test/resources/h2.sql =================================================================== --- artemis/trunk/jiemamy-composer/src/test/resources/h2.sql (rev 0) +++ artemis/trunk/jiemamy-composer/src/test/resources/h2.sql 2009-02-24 10:59:15 UTC (rev 2724) @@ -0,0 +1,101 @@ + +-- define: T_USER +CREATE TABLE T_USER ( + USER_ID SERIAL NOT NULL PRIMARY KEY, + USERNAME VARCHAR(32) NOT NULL UNIQUE, + PASSWORD CHAR(32) NOT NULL, + EMAIL VARCHAR(128) NOT NULL, + CREATE_TS TIMESTAMP DEFAULT CURRENT_TIMESTAMP() NOT NULL, + UPDATE_TS TIMESTAMP DEFAULT CURRENT_TIMESTAMP() NOT NULL, + DELETE_TS TIMESTAMP +); + +INSERT INTO T_USER (USERNAME, PASSWORD, EMAIL) + VALUES ('daisuke', 'a2b200758e247a492959ae067d581367', 'daisuke_m****@yahoo*****'); +INSERT INTO T_USER (USERNAME, PASSWORD, EMAIL) + VALUES ('bose999', '4ddb3bc340b268a16a08f52c9dc6f695', 'daisuke_m****@yahoo*****'); +INSERT INTO T_USER (USERNAME, PASSWORD, EMAIL) + VALUES ('ykhr', '99700b1eb62a1ba13a059bf3940fd463', 'daisuke_m****@yahoo*****'); + + +-- define: T_POLL +CREATE TABLE T_POLL ( + POLL_ID SERIAL NOT NULL PRIMARY KEY, + TITLE VARCHAR(128) NOT NULL, + DESCRIPTION TEXT NOT NULL, + CONCLUSION TEXT, + OWNER_ID INTEGER NOT NULL, + NOTIFIED BOOLEAN NOT NULL, + OPEN_TS TIMESTAMP NOT NULL, + CLOSE_TS TIMESTAMP NOT NULL, + CREATE_TS TIMESTAMP DEFAULT CURRENT_TIMESTAMP() NOT NULL, + UPDATE_TS TIMESTAMP DEFAULT CURRENT_TIMESTAMP() NOT NULL, + DELETE_TS TIMESTAMP, + CONSTRAINT fkey_T_POLL_T_USER FOREIGN KEY (OWNER_ID) + REFERENCES T_USER (USER_ID) + ON DELETE SET NULL + ON UPDATE CASCADE +); + +INSERT INTO T_POLL (TITLE, DESCRIPTION, OWNER_ID, OPEN_TS, CLOSE_TS, DELETE_TS, NOTIFIED) + VALUES ('投票1', '投票1desc', 1, '2008-06-01 00:00:00', '2008-07-01 00:00:00', NULL, false); +INSERT INTO T_POLL (TITLE, DESCRIPTION, OWNER_ID, OPEN_TS, CLOSE_TS, DELETE_TS, NOTIFIED) + VALUES ('投票2', '投票2desc', 2, '2008-06-01 00:00:00', '2008-07-01 00:00:00', NULL, false); + + +-- define: T_CHOICE +CREATE TABLE T_CHOICE ( + CHOICE_ID SERIAL NOT NULL PRIMARY KEY, + POLL_ID INTEGER NOT NULL, + NAME VARCHAR(64) NOT NULL, + CREATE_TS TIMESTAMP DEFAULT CURRENT_TIMESTAMP() NOT NULL, + UPDATE_TS TIMESTAMP DEFAULT CURRENT_TIMESTAMP() NOT NULL, + DELETE_TS TIMESTAMP, + CONSTRAINT fkey_T_CHOICE_T_POLL FOREIGN KEY (POLL_ID) + REFERENCES T_POLL (POLL_ID) + ON DELETE CASCADE + ON UPDATE CASCADE +); + +INSERT INTO T_CHOICE (POLL_ID, NAME, DELETE_TS) + VALUES (1, '1-1', NULL); +INSERT INTO T_CHOICE (POLL_ID, NAME, DELETE_TS) + VALUES (1, '1-2', NULL); +INSERT INTO T_CHOICE (POLL_ID, NAME, DELETE_TS) + VALUES (2, '2-1', NULL); +INSERT INTO T_CHOICE (POLL_ID, NAME, DELETE_TS) + VALUES (2, '2-2', NULL); + + +-- define: T_VOTE +CREATE TABLE T_VOTE ( + VOTE_ID SERIAL NOT NULL PRIMARY KEY, + USER_ID INTEGER NOT NULL, + POLL_ID INTEGER NOT NULL, + CHOICE_ID INTEGER NOT NULL, + COMMENT VARCHAR(255), + CREATE_TS TIMESTAMP DEFAULT CURRENT_TIMESTAMP() NOT NULL, + UPDATE_TS TIMESTAMP DEFAULT CURRENT_TIMESTAMP() NOT NULL, + DELETE_TS TIMESTAMP, + CONSTRAINT fkey_T_VOTE_T_USER FOREIGN KEY (USER_ID) + REFERENCES T_USER (USER_ID) + ON DELETE CASCADE + ON UPDATE CASCADE, + CONSTRAINT fkey_T_VOTE_T_POLL FOREIGN KEY (POLL_ID) + REFERENCES T_POLL (POLL_ID) + ON DELETE CASCADE + ON UPDATE CASCADE, + CONSTRAINT fkey_T_VOTE_T_CHOICE FOREIGN KEY (CHOICE_ID) + REFERENCES T_CHOICE (CHOICE_ID) + ON DELETE RESTRICT + ON UPDATE CASCADE +); + +INSERT INTO T_VOTE (USER_ID, POLL_ID, CHOICE_ID, DELETE_TS) + VALUES (1, 1, 1, NULL); +INSERT INTO T_VOTE (USER_ID, POLL_ID, CHOICE_ID) + VALUES (2, 1, 2); +INSERT INTO T_VOTE (USER_ID, POLL_ID, CHOICE_ID) + VALUES (2, 2, 3); + + Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/attribute/ColumnModelImpl.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/attribute/ColumnModelImpl.java 2009-02-24 01:27:03 UTC (rev 2723) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/attribute/ColumnModelImpl.java 2009-02-24 10:59:15 UTC (rev 2724) @@ -20,6 +20,7 @@ import java.util.UUID; +import org.apache.commons.lang.Validate; import org.apache.commons.lang.builder.ToStringBuilder; import org.apache.commons.lang.builder.ToStringStyle; @@ -61,6 +62,7 @@ */ public ColumnModelImpl(Jiemamy jiemamy, UUID id) { super(jiemamy, id); + setName(""); } public ColumnCheckModel getCheck() { @@ -99,6 +101,12 @@ this.defaultValue = defaultValue; } + @Override + public void setName(String name) { + Validate.notNull(name); + super.setName(name); + } + public void setNotNull(NotNullConstraintModel notNull) { this.notNull = notNull; } Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/entity/AbstractEntityModel.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/entity/AbstractEntityModel.java 2009-02-24 01:27:03 UTC (rev 2723) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/entity/AbstractEntityModel.java 2009-02-24 10:59:15 UTC (rev 2724) @@ -20,6 +20,8 @@ import java.util.UUID; +import org.apache.commons.lang.Validate; + import org.jiemamy.Jiemamy; import org.jiemamy.model.AbstractJiemamyElement; @@ -31,7 +33,7 @@ public abstract class AbstractEntityModel extends AbstractJiemamyElement implements EntityModel { /** 名前 */ - private String name; + private String name = ""; /** 論理名 */ private String logicalName; @@ -94,6 +96,7 @@ } public void setName(String name) { + Validate.notNull(name); this.name = name; } Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/entity/ViewModelImpl.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/entity/ViewModelImpl.java 2009-02-24 01:27:03 UTC (rev 2723) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/entity/ViewModelImpl.java 2009-02-24 10:59:15 UTC (rev 2724) @@ -20,6 +20,8 @@ import java.util.UUID; +import org.apache.commons.lang.Validate; + import org.jiemamy.Jiemamy; /** @@ -30,7 +32,7 @@ public class ViewModelImpl extends AbstractEntityModel implements ViewModel { /** VIEW定義SELECT文 */ - private String definition; + private String definition = ""; /** @@ -49,6 +51,7 @@ } public void setDefinition(String definition) { + Validate.notNull(definition); this.definition = definition; } } Modified: zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/attribute/AttributeModel.java =================================================================== --- zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/attribute/AttributeModel.java 2009-02-24 01:27:03 UTC (rev 2723) +++ zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/attribute/AttributeModel.java 2009-02-24 10:59:15 UTC (rev 2724) @@ -68,6 +68,7 @@ * 物理名を設定する。 * * @param name 物理名 + * @throws IllegalArgumentException {@code null}を許可しない実装の引数に{@code null}を与えた場合 */ void setName(String name); Modified: zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/entity/EntityModel.java =================================================================== --- zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/entity/EntityModel.java 2009-02-24 01:27:03 UTC (rev 2723) +++ zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/entity/EntityModel.java 2009-02-24 10:59:15 UTC (rev 2724) @@ -94,6 +94,7 @@ * エンティティ名を設定する。 * * @param name エンティティ名 + * @throws IllegalArgumentException 引数に{@code null}を与えた場合 */ void setName(String name); } Modified: zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/entity/ViewModel.java =================================================================== --- zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/entity/ViewModel.java 2009-02-24 01:27:03 UTC (rev 2723) +++ zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/entity/ViewModel.java 2009-02-24 10:59:15 UTC (rev 2724) @@ -35,6 +35,7 @@ * VIEW定義SELECT文を設定する。 * * @param definition VIEW定義SELECT文 + * @throws IllegalArgumentException 引数に{@code null}を与えた場合 */ void setDefinition(String definition);