From: <fg...@us...> - 2008-01-31 13:13:36
|
Revision: 578 http://openutils.svn.sourceforge.net/openutils/?rev=578&view=rev Author: fgiust Date: 2008-01-31 05:13:40 -0800 (Thu, 31 Jan 2008) Log Message: ----------- a few fixes, start tracking changes in changes.xml Modified Paths: -------------- trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitExecution.java trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitTestContext.java trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitUtils.java Added Paths: ----------- trunk/openutils-testing/src/main/java/it/openutils/testing/dbunit/ trunk/openutils-testing/src/main/java/it/openutils/testing/dbunit/CleanInsertOperation.java trunk/openutils-testing/src/main/java/it/openutils/testing/dbunit/MsSqlIndentityCleanInsertOperation.java trunk/openutils-testing/src/main/java/it/openutils/testing/dbunit/MsSqlIndentityInsertOperation.java trunk/openutils-testing/src/main/java/it/openutils/testing/dbunit/MySqlAbstractNoFkOperation.java trunk/openutils-testing/src/main/java/it/openutils/testing/dbunit/MySqlNoFkCleanInsertOperation.java trunk/openutils-testing/src/main/java/it/openutils/testing/dbunit/MySqlNoFkInsertOperation.java trunk/openutils-testing/src/main/java/it/openutils/testing/dbunit/MySqlNoFkTruncateOperation.java trunk/openutils-testing/src/site/changes/ trunk/openutils-testing/src/site/changes/changes.xml Modified: trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitExecution.java =================================================================== --- trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitExecution.java 2008-01-30 21:24:20 UTC (rev 577) +++ trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitExecution.java 2008-01-31 13:13:40 UTC (rev 578) @@ -65,10 +65,9 @@ boolean truncateAll() default true; /** - * The database operation that will be used to truncate tables. Defaults to - * org.dbunit.operation.TruncateTableOperation + * The database operation that will be used to truncate tables. Defaults to org.dbunit.operation.DeleteAllOperation */ - Class< ? extends DatabaseOperation> truncateOperation() default org.dbunit.operation.TruncateTableOperation.class; + Class< ? extends DatabaseOperation> truncateOperation() default org.dbunit.operation.DeleteAllOperation.class; /** * The database operation that will be used to load datasets. Defaults to org.dbunit.operation.InsertOperation Modified: trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitTestContext.java =================================================================== --- trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitTestContext.java 2008-01-30 21:24:20 UTC (rev 577) +++ trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitTestContext.java 2008-01-31 13:13:40 UTC (rev 578) @@ -267,19 +267,28 @@ log.debug("Generating sorted dataset for initial cleanup"); IDataSet unsortedDataSet = connection.createDataSet(); - log.debug("Unfiltered truncateDataSet: {}", ArrayUtils.toString(unsortedDataSet.getTableNames())); + if (log.isDebugEnabled()) + { + log.debug("Unfiltered truncateDataSet: {}", ArrayUtils.toString(unsortedDataSet.getTableNames())); + } - ITableFilter filter = new DatabaseSequenceFilter(connection, new FilteredDataSet( - tableFilter, - unsortedDataSet).getTableNames()); - truncateDataSet = new FilteredDataSet(tableFilter, new FilteredDataSet(filter, unsortedDataSet)); + // excluded unwanted tables + unsortedDataSet = new FilteredDataSet(tableFilter, unsortedDataSet); + + // sort tables + ITableFilter sortingFilter = new DatabaseSequenceFilter(connection, unsortedDataSet.getTableNames()); + truncateDataSet = new FilteredDataSet(sortingFilter, unsortedDataSet); + storeTruncateDataset(dataSourceName, connection.getSchema(), truncateDataSet); log.debug("Sorted dataset generated"); } - log.debug("Tables truncateDataSet: {}", ArrayUtils.toString(truncateDataSet.getTableNames())); if (truncateDataSet != null) { + if (log.isDebugEnabled()) + { + log.debug("Tables truncateDataSet: {}", ArrayUtils.toString(truncateDataSet.getTableNames())); + } databaseOperation.execute(connection, truncateDataSet); } } Modified: trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitUtils.java =================================================================== --- trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitUtils.java 2008-01-30 21:24:20 UTC (rev 577) +++ trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitUtils.java 2008-01-31 13:13:40 UTC (rev 578) @@ -89,7 +89,6 @@ } finally { - connection.close(); fos.close(); } Added: trunk/openutils-testing/src/main/java/it/openutils/testing/dbunit/CleanInsertOperation.java =================================================================== --- trunk/openutils-testing/src/main/java/it/openutils/testing/dbunit/CleanInsertOperation.java (rev 0) +++ trunk/openutils-testing/src/main/java/it/openutils/testing/dbunit/CleanInsertOperation.java 2008-01-31 13:13:40 UTC (rev 578) @@ -0,0 +1,40 @@ +/* + * Copyright Openmind http://www.openmindonline.it + * + * 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 it.openutils.testing.dbunit; + +import org.dbunit.operation.CompositeOperation; +import org.dbunit.operation.DatabaseOperation; + + +/** + * Mimics the standard <code>DatabaseOperation.CLEAN_INSERT</code> operation with an empty constructor (can be used in + * annotations). + * @author fgiust + * @version $Id: $ + */ +public class CleanInsertOperation extends CompositeOperation +{ + + /** + * @param action1 + * @param action2 + */ + public CleanInsertOperation() + { + super(DatabaseOperation.DELETE_ALL, DatabaseOperation.INSERT); + } + +} Property changes on: trunk/openutils-testing/src/main/java/it/openutils/testing/dbunit/CleanInsertOperation.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Added: trunk/openutils-testing/src/main/java/it/openutils/testing/dbunit/MsSqlIndentityCleanInsertOperation.java =================================================================== --- trunk/openutils-testing/src/main/java/it/openutils/testing/dbunit/MsSqlIndentityCleanInsertOperation.java (rev 0) +++ trunk/openutils-testing/src/main/java/it/openutils/testing/dbunit/MsSqlIndentityCleanInsertOperation.java 2008-01-31 13:13:40 UTC (rev 578) @@ -0,0 +1,40 @@ +/* + * Copyright Openmind http://www.openmindonline.it + * + * 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 it.openutils.testing.dbunit; + +import org.dbunit.ext.mssql.InsertIdentityOperation; +import org.dbunit.operation.DatabaseOperation; + + +/** + * Extends the standard org.dbunit.ext.mssql.InsertIdentityOperation in order to be able to use this class directly in a + * annotation. Wraps a <code>DatabaseOperation.CLEAN_INSERT</code> operation. + * @see org.dbunit.ext.mssql.InsertIdentityOperation + * @author fgiust + * @version $Id: $ + */ +public class MsSqlIndentityCleanInsertOperation extends InsertIdentityOperation +{ + + /** + * @param operation + */ + public MsSqlIndentityCleanInsertOperation() + { + super(DatabaseOperation.CLEAN_INSERT); + } + +} Property changes on: trunk/openutils-testing/src/main/java/it/openutils/testing/dbunit/MsSqlIndentityCleanInsertOperation.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Added: trunk/openutils-testing/src/main/java/it/openutils/testing/dbunit/MsSqlIndentityInsertOperation.java =================================================================== --- trunk/openutils-testing/src/main/java/it/openutils/testing/dbunit/MsSqlIndentityInsertOperation.java (rev 0) +++ trunk/openutils-testing/src/main/java/it/openutils/testing/dbunit/MsSqlIndentityInsertOperation.java 2008-01-31 13:13:40 UTC (rev 578) @@ -0,0 +1,40 @@ +/* + * Copyright Openmind http://www.openmindonline.it + * + * 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 it.openutils.testing.dbunit; + +import org.dbunit.ext.mssql.InsertIdentityOperation; +import org.dbunit.operation.DatabaseOperation; + + +/** + * Extends the standard org.dbunit.ext.mssql.InsertIdentityOperation in order to be able to use this class directly in a + * annotation. Wraps a <code>DatabaseOperation.INSERT</code> operation. + * @see org.dbunit.ext.mssql.InsertIdentityOperation + * @author fgiust + * @version $Id: $ + */ +public class MsSqlIndentityInsertOperation extends InsertIdentityOperation +{ + + /** + * @param operation + */ + public MsSqlIndentityInsertOperation() + { + super(DatabaseOperation.INSERT); + } + +} Property changes on: trunk/openutils-testing/src/main/java/it/openutils/testing/dbunit/MsSqlIndentityInsertOperation.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Added: trunk/openutils-testing/src/main/java/it/openutils/testing/dbunit/MySqlAbstractNoFkOperation.java =================================================================== --- trunk/openutils-testing/src/main/java/it/openutils/testing/dbunit/MySqlAbstractNoFkOperation.java (rev 0) +++ trunk/openutils-testing/src/main/java/it/openutils/testing/dbunit/MySqlAbstractNoFkOperation.java 2008-01-31 13:13:40 UTC (rev 578) @@ -0,0 +1,90 @@ +/* + * Copyright Openmind http://www.openmindonline.it + * + * 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 it.openutils.testing.dbunit; + +import java.sql.Connection; +import java.sql.SQLException; +import java.sql.Statement; + +import org.dbunit.DatabaseUnitException; +import org.dbunit.database.IDatabaseConnection; +import org.dbunit.dataset.IDataSet; +import org.dbunit.operation.AbstractOperation; +import org.dbunit.operation.DatabaseOperation; +import org.dbunit.operation.ExclusiveTransactionException; + + +/** + * Extended operation for dbunit that disables FK checks. + * @author fgiust + * @version $Id: $ + */ +public class MySqlAbstractNoFkOperation extends AbstractOperation +{ + + /** + * Wrapped operation. + */ + private final DatabaseOperation operation; + + /** + * Creates a new InsertIdentityOperation object that decorates the specified operation. + * @param operation wrapped operation + */ + public MySqlAbstractNoFkOperation(DatabaseOperation operation) + { + this.operation = operation; + } + + /** + * {@inheritDoc} + */ + @Override + public void execute(IDatabaseConnection connection, IDataSet dataSet) throws DatabaseUnitException, SQLException + { + Connection jdbcConnection = connection.getConnection(); + Statement statement = jdbcConnection.createStatement(); + + try + { + if (!jdbcConnection.getAutoCommit()) + { + throw new ExclusiveTransactionException(); + } + jdbcConnection.setAutoCommit(false); + + // disable FK + statement.execute("SET FOREIGN_KEY_CHECKS=0"); + + try + { + operation.execute(connection, connection.createDataSet()); + } + finally + { + // enable FK + statement.execute("SET FOREIGN_KEY_CHECKS=1"); + jdbcConnection.commit(); + } + + } + finally + { + jdbcConnection.setAutoCommit(true); + statement.close(); + } + } +} Property changes on: trunk/openutils-testing/src/main/java/it/openutils/testing/dbunit/MySqlAbstractNoFkOperation.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Added: trunk/openutils-testing/src/main/java/it/openutils/testing/dbunit/MySqlNoFkCleanInsertOperation.java =================================================================== --- trunk/openutils-testing/src/main/java/it/openutils/testing/dbunit/MySqlNoFkCleanInsertOperation.java (rev 0) +++ trunk/openutils-testing/src/main/java/it/openutils/testing/dbunit/MySqlNoFkCleanInsertOperation.java 2008-01-31 13:13:40 UTC (rev 578) @@ -0,0 +1,37 @@ +/* + * Copyright Openmind http://www.openmindonline.it + * + * 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 it.openutils.testing.dbunit; + +import org.dbunit.operation.DatabaseOperation; + + +/** + * Extended operation for dbunit that disables FK checks. + * @author fgiust + * @version $Id: $ + */ +public class MySqlNoFkCleanInsertOperation extends MySqlAbstractNoFkOperation +{ + + /** + * @param operation + */ + public MySqlNoFkCleanInsertOperation() + { + super(DatabaseOperation.TRUNCATE_TABLE); + } + +} Property changes on: trunk/openutils-testing/src/main/java/it/openutils/testing/dbunit/MySqlNoFkCleanInsertOperation.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Added: trunk/openutils-testing/src/main/java/it/openutils/testing/dbunit/MySqlNoFkInsertOperation.java =================================================================== --- trunk/openutils-testing/src/main/java/it/openutils/testing/dbunit/MySqlNoFkInsertOperation.java (rev 0) +++ trunk/openutils-testing/src/main/java/it/openutils/testing/dbunit/MySqlNoFkInsertOperation.java 2008-01-31 13:13:40 UTC (rev 578) @@ -0,0 +1,37 @@ +/* + * Copyright Openmind http://www.openmindonline.it + * + * 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 it.openutils.testing.dbunit; + +import org.dbunit.operation.DatabaseOperation; + + +/** + * Extended operation for dbunit that disables FK checks. + * @author fgiust + * @version $Id: $ + */ +public class MySqlNoFkInsertOperation extends MySqlAbstractNoFkOperation +{ + + /** + * @param operation + */ + public MySqlNoFkInsertOperation() + { + super(DatabaseOperation.TRUNCATE_TABLE); + } + +} Property changes on: trunk/openutils-testing/src/main/java/it/openutils/testing/dbunit/MySqlNoFkInsertOperation.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Added: trunk/openutils-testing/src/main/java/it/openutils/testing/dbunit/MySqlNoFkTruncateOperation.java =================================================================== --- trunk/openutils-testing/src/main/java/it/openutils/testing/dbunit/MySqlNoFkTruncateOperation.java (rev 0) +++ trunk/openutils-testing/src/main/java/it/openutils/testing/dbunit/MySqlNoFkTruncateOperation.java 2008-01-31 13:13:40 UTC (rev 578) @@ -0,0 +1,37 @@ +/* + * Copyright Openmind http://www.openmindonline.it + * + * 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 it.openutils.testing.dbunit; + +import org.dbunit.operation.DatabaseOperation; + + +/** + * Extended operation for dbunit that disables FK checks. + * @author fgiust + * @version $Id: $ + */ +public class MySqlNoFkTruncateOperation extends MySqlAbstractNoFkOperation +{ + + /** + * @param operation + */ + public MySqlNoFkTruncateOperation() + { + super(DatabaseOperation.TRUNCATE_TABLE); + } + +} Property changes on: trunk/openutils-testing/src/main/java/it/openutils/testing/dbunit/MySqlNoFkTruncateOperation.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Added: trunk/openutils-testing/src/site/changes/changes.xml =================================================================== --- trunk/openutils-testing/src/site/changes/changes.xml (rev 0) +++ trunk/openutils-testing/src/site/changes/changes.xml 2008-01-31 13:13:40 UTC (rev 578) @@ -0,0 +1,31 @@ +<?xml version="1.0"?> +<!-- + "type" attribute can be: add, remove, update or fix. +--> +<document> + <properties> + <title>Changes</title> + <author email="fgiust(at)users.sourceforge.net">Fabrizio Giustina</author> + </properties> + <body> + <release version="2.0.2" date="in svn" description="2.0.2"> + <action type="add" dev="fgiust"> + New dbunit operation classes for mssql and mysql (extension of standard dbunit operation, but refactored so that + they can be used in annotations). See the javadocs in the it.openutils.testing.dbunit package + </action> + <action type="update" dev="fgiust"> + truncate operation now defaults to DbUnitOperation.DELETE_ALL instead of DbUnitOperation.TRUNCATE. + </action> + <action type="fix" dev="fgiust">DbUnitUtils.exportDataset() doesn't close anymore the provided connection</action> + </release> + <release version="2.0.1" date="2008-01-30" description="2.0.1"> + <action type="fix" dev="fgiust"> + (junit version only). it.openutils.testing.junit.AbstractDbUnitJunitSpringContextTests was totally broken due to + the setup method being protected. Fixed + added tests + </action> + </release> + <release version="2.0" date="2008-01-20" description="2.0 release"> + <action type="update" dev="fgiust">Totally reworked dbunit test framework.</action> + </release> + </body> +</document> \ No newline at end of file Property changes on: trunk/openutils-testing/src/site/changes/changes.xml ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fg...@us...> - 2008-01-31 22:18:47
|
Revision: 579 http://openutils.svn.sourceforge.net/openutils/?rev=579&view=rev Author: fgiust Date: 2008-01-31 14:18:50 -0800 (Thu, 31 Jan 2008) Log Message: ----------- new utility method Modified Paths: -------------- trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitUtils.java trunk/openutils-testing/src/site/changes/changes.xml Modified: trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitUtils.java =================================================================== --- trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitUtils.java 2008-01-31 13:13:40 UTC (rev 578) +++ trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitUtils.java 2008-01-31 22:18:50 UTC (rev 579) @@ -29,6 +29,7 @@ import org.dbunit.dataset.FilteredDataSet; import org.dbunit.dataset.IDataSet; import org.dbunit.dataset.excel.XlsDataSet; +import org.dbunit.dataset.filter.ITableFilter; import org.dbunit.dataset.xml.XmlDataSet; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -96,6 +97,38 @@ } /** + * Exports a full db saving a dataset for each table. + * @param connection dbunit connection + * @param directory export directory + * @param xls if <code>true</code> export will be done using excel datasets + * @param tableFilter optional table filter + * @throws SQLException sql exception + * @throws DataSetException dbunit exception + * @throws IOException IO exception + */ + public void exportTablesToDir(IDatabaseConnection connection, File directory, boolean xls, ITableFilter tableFilter) + throws SQLException, DataSetException, IOException + + { + directory.mkdirs(); + + IDataSet dataset = connection.createDataSet(); + if (tableFilter != null) + { + dataset = new FilteredDataSet(tableFilter, dataset); + } + + String[] tablenames = dataset.getTableNames(); + + for (String table : tablenames) + { + File exportFile = new File(directory, table + (xls ? ".xls" : ".xml")); + log.info("Exporting {}", table); + DbUnitUtils.exportDataset(connection, new String[]{table }, exportFile); + } + } + + /** * @param url dataset url (can be an xml or excel file) * @return loaded dataset * @throws IOException error reading the file Modified: trunk/openutils-testing/src/site/changes/changes.xml =================================================================== --- trunk/openutils-testing/src/site/changes/changes.xml 2008-01-31 13:13:40 UTC (rev 578) +++ trunk/openutils-testing/src/site/changes/changes.xml 2008-01-31 22:18:50 UTC (rev 579) @@ -17,6 +17,7 @@ truncate operation now defaults to DbUnitOperation.DELETE_ALL instead of DbUnitOperation.TRUNCATE. </action> <action type="fix" dev="fgiust">DbUnitUtils.exportDataset() doesn't close anymore the provided connection</action> + <action type="add" dev="fgiust">new DbUnitUtils.exportTablesToDir() utility method</action> </release> <release version="2.0.1" date="2008-01-30" description="2.0.1"> <action type="fix" dev="fgiust"> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fg...@us...> - 2008-02-17 09:03:02
|
Revision: 618 http://openutils.svn.sourceforge.net/openutils/?rev=618&view=rev Author: fgiust Date: 2008-02-17 01:03:04 -0800 (Sun, 17 Feb 2008) Log Message: ----------- minor improvements to DateAssert Modified Paths: -------------- trunk/openutils-testing/src/main/java/it/openutils/testing/DateAssert.java trunk/openutils-testing/src/site/changes/changes.xml Modified: trunk/openutils-testing/src/main/java/it/openutils/testing/DateAssert.java =================================================================== --- trunk/openutils-testing/src/main/java/it/openutils/testing/DateAssert.java 2008-02-14 16:06:03 UTC (rev 617) +++ trunk/openutils-testing/src/main/java/it/openutils/testing/DateAssert.java 2008-02-17 09:03:04 UTC (rev 618) @@ -43,18 +43,22 @@ } /** - * Asserts that two dates are equal. - * @param expectedDateAsString date formatted as "YYYYMMDD" - * @param date actual date - * @throws IllegalArgumentException if <code>expectedDateAsString</code> is not a valid date format + * @param expectedDateAsString + * @param date + * @param format + * @throws AssertionError */ - public static void dateEqual(String expectedDateAsString, Calendar date) throws IllegalArgumentException + private static void performComparison(String expectedDateAsString, Date date, DateFormat format) + throws AssertionError { Date expected; try { - expected = df.parse(expectedDateAsString); + synchronized (format) + { + expected = format.parse(expectedDateAsString); + } } catch (ParseException e) { @@ -65,40 +69,51 @@ { throw new AssertionError("Date is null"); } - if (!date.getTime().equals(expected)) + if (!date.equals(expected)) { - throw new AssertionError("Expected <" + expected + ">, actual <" + date.getTime() + ">"); + synchronized (format) + { + throw new AssertionError("Expected <" + + format.format(expected) + + ">, actual <" + + format.format(date) + + ">"); + } } } /** * Asserts that two dates are equal. + * @param expectedDateAsString date formatted as "YYYYMMDD" + * @param date actual date + * @throws IllegalArgumentException if <code>expectedDateAsString</code> is not a valid date format + */ + public static void dateEqual(String expectedDateAsString, Calendar date) throws IllegalArgumentException + { + performComparison(expectedDateAsString, date.getTime(), df); + } + + /** + * Asserts that two dates are equal. + * @param expectedDateAsString date formatted as "YYYYMMDD" + * @param date actual date + * @throws IllegalArgumentException if <code>expectedDateAsString</code> is not a valid date format + */ + public static void dateEqual(String expectedDateAsString, Date date) throws IllegalArgumentException + { + performComparison(expectedDateAsString, date, df); + } + + /** + * Asserts that two dates are equal. * @param expectedDateAsString date formatted as "yyyyMMdd HH:mm" * @param date actual date * @throws IllegalArgumentException if <code>expectedDateAsString</code> is not a valid date format */ public static void dateTimeEqual(String expectedDateAsString, Date date) throws IllegalArgumentException { - Date expected; - try - { - expected = dtf.parse(expectedDateAsString); - } - catch (ParseException e) - { - throw new IllegalArgumentException("Unparseable date String: [" + expectedDateAsString + "]"); - } - - if (date == null) - { - throw new AssertionError("Date is null"); - } - - if (date.getTime() != expected.getTime()) - { - throw new AssertionError("Expected <" + expected + ">, actual <" + date + ">"); - } + performComparison(expectedDateAsString, date, dtf); } /** Modified: trunk/openutils-testing/src/site/changes/changes.xml =================================================================== --- trunk/openutils-testing/src/site/changes/changes.xml 2008-02-14 16:06:03 UTC (rev 617) +++ trunk/openutils-testing/src/site/changes/changes.xml 2008-02-17 09:03:04 UTC (rev 618) @@ -8,7 +8,12 @@ <author email="fgiust(at)users.sourceforge.net">Fabrizio Giustina</author> </properties> <body> - <release version="2.0.2" date="in svn" description="2.0.2"> + <release version="2.0.3" date="in svn" description="2.0.2"> + <action type="update" dev="fgiust"> + it.openutils.testing.DateAssert is now thread safe. Failure messages have been improved. + </action> + </release> + <release version="2.0.2" date="2008-01-31" description="2.0.2"> <action type="add" dev="fgiust"> New dbunit operation classes for mssql and mysql (extension of standard dbunit operation, but refactored so that they can be used in annotations). See the javadocs in the it.openutils.testing.dbunit package This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fg...@us...> - 2008-04-27 09:45:17
|
Revision: 752 http://openutils.svn.sourceforge.net/openutils/?rev=752&view=rev Author: fgiust Date: 2008-04-27 02:45:03 -0700 (Sun, 27 Apr 2008) Log Message: ----------- nearly ready for 2.1 Modified Paths: -------------- trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitExecution.java trunk/openutils-testing/src/site/changes/changes.xml Modified: trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitExecution.java =================================================================== --- trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitExecution.java 2008-03-20 17:39:12 UTC (rev 751) +++ trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitExecution.java 2008-04-27 09:45:03 UTC (rev 752) @@ -22,6 +22,7 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import org.dbunit.dataset.datatype.DefaultDataTypeFactory; import org.dbunit.dataset.datatype.IDataTypeFactory; import org.dbunit.operation.DatabaseOperation; @@ -57,7 +58,7 @@ /** * The datatype factory (DatabaseConfig.PROPERTY_DATATYPE_FACTORY) to use. Can be left unset if not needed. */ - Class< ? extends IDataTypeFactory> dataTypeFactory(); + Class< ? extends IDataTypeFactory> dataTypeFactory() default DefaultDataTypeFactory.class; /** * A regexp that can match table names. Any table matching this regular expression will not be considered by DbUnit. Modified: trunk/openutils-testing/src/site/changes/changes.xml =================================================================== --- trunk/openutils-testing/src/site/changes/changes.xml 2008-03-20 17:39:12 UTC (rev 751) +++ trunk/openutils-testing/src/site/changes/changes.xml 2008-04-27 09:45:03 UTC (rev 752) @@ -8,15 +8,17 @@ <author email="fgiust(at)users.sourceforge.net">Fabrizio Giustina</author> </properties> <body> - <release version="2.0.3" date="in svn" description="2.0.3"> + <release version="2.1" date="in svn" description="2.1"> + <action type="update" dev="fgiust">Legacy base test classes (DbUnitTestCase, GenericsDbUnitTestCase) have been + dropped. Stick with 2.0.x if you are still use them or upgrade to 2.1 for a forced migration</action> <action type="fix" dev="fgiust"> excludedTables in DbUnitExecution now defaults to "^BIN\\$(.*)", properly excluding tables in oracle recycle bin.</action> + <action type="add" dev="fcarone"> New option for DbUnitExection to specify the + DatabaseConfig.PROPERTY_DATATYPE_FACTORY added.</action> </release> <release version="2.0.3" date="2008-02-19" description="2.0.3"> <action type="update" dev="fgiust"> it.openutils.testing.DateAssert is now thread safe. Failure messages have been improved.</action> - <action type="add" dev="fcarone"> New option for DbUnitExection to specify the - DatabaseConfig.PROPERTY_DATATYPE_FACTORY added.</action> </release> <release version="2.0.2" date="2008-01-31" description="2.0.2"> <action type="add" dev="fgiust"> New dbunit operation classes for mssql and mysql (extension of standard dbunit This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |