|
View:
New views
1 Messages
—
Rating Filter:
Alert me
|
|
|
Looking for volunteers to help with refactoring/test writingI have the first few *Statement/*Generator classes cleaned
up and at 100% test coverage. To keep the refactoring going, I am hoping
I could get a couple volunteers to help clean up and write tests around the
rest of the statement/generator classes. What needs to be done for each Generator class is: 1.
Take a look at the generateSql() method and decide if
the different database outputs warrant a database-specific generator.
Split the Generator as nessisary 2.
Create unit tests for the generators using the testSql*
test methods. The way these methods are set up is that they do a string
comparison to a baseline SQL string that is hard coded in to the test. If
that comparison passes, the SQL is ran against the database to check for syntax
errors. We are not checking that the SQL actually does what it is
supposed to since we should be able to tell that looking at the baseline sql 3.
Update test/generators until they actually pass against
real databases you have on your machine. If you find combinations of
inputs to a generator that are not valid for a database, add it to the
validate() method checks that make sure the passed Statement class is correct. It is not difficult work, and it does not require an
in-depth knowledge of the liquibase internals, but it takes time. So, if
you are interested in jumping into the liquibase codebase and/or would like to
help free me up to move to refactoring other portions of the code, let me know
(via this list or directly) and I can coordinate efforts and answer questions. Example code if you are interested: public class AddAutoIncrementGenerator implements
SqlGenerator<AddAutoIncrementStatement> { public int getSpecializationLevel() { return
SPECIALIZATION_LEVEL_DEFAULT; } public boolean
isValidGenerator(AddAutoIncrementStatement statement, Database database) { return
(database.supportsAutoIncrement()
&& !(database instanceof DerbyDatabase)
&& !(database instanceof HsqlDatabase)); } public GeneratorValidationErrors
validate(AddAutoIncrementStatement addAutoIncrementStatement, Database
database) { return new
GeneratorValidationErrors(); } public Sql[]
generateSql(AddAutoIncrementStatement statement, Database database) throws
JDBCException { String sql =
"ALTER TABLE "
+ database.escapeTableName(statement.getSchemaName(), statement.getTableName())
+ " MODIFY " + database.escapeColumnName(statement.getSchemaName(),
statement.getTableName(), statement.getColumnName())
+ " " + database.getColumnType(statement.getColumnDataType(), true)
+ " AUTO_INCREMENT"; return new Sql[]
{
new UnparsedSql(sql) }; } } public class AddAutoIncrementGeneratorTest extends
AbstractSqlGeneratorTest { public AddAutoIncrementGeneratorTest() { this(new
AddAutoIncrementGenerator()); } public
AddAutoIncrementGeneratorTest(SqlGenerator generatorUnderTest) {
super(generatorUnderTest); } protected SqlStatement[]
setupStatements() { return new
SqlStatement[]{
new CreateTableStatement(null, "table_name") .addColumn("id",
"int", new PrimaryKeyConstraint()) }; } protected AddAutoIncrementStatement
createSampleSqlStatement() { return new
AddAutoIncrementStatement(null, null, null, null); } @Test public void generateSql_noSchema() throws
Exception {
AddAutoIncrementStatement statement = new AddAutoIncrementStatement(null,
"table_name", "id", "int");
testSqlOnAllExcept("ALTER TABLE [table_name] MODIFY [id] int AUTO_INCREMENT",
statement, PostgresDatabase.class);
testSqlOn("alter table [table_name] modify id serial auto_increment",
statement, PostgresDatabase.class); } @Override protected boolean
shouldBeImplementation(Database database) { return
database.supportsAutoIncrement() && !(database instanceof
DerbyDatabase); } } Thanks in advance, Nathan ------------------------------------------------------------------------------ Crystal Reports - New Free Runtime and 30 Day Trial Check out the new simplified licensign option that enables unlimited royalty-free distribution of the report engine for externally facing server and web deployment. http://p.sf.net/sfu/businessobjects _______________________________________________ Liquibase-devel mailing list Liquibase-devel@... https://lists.sourceforge.net/lists/listinfo/liquibase-devel |
| Free embeddable forum powered by Nabble | Forum Help |