|
From: <fg...@us...> - 2008-01-08 09:26:19
|
Revision: 518
http://openutils.svn.sourceforge.net/openutils/?rev=518&view=rev
Author: fgiust
Date: 2008-01-08 01:26:20 -0800 (Tue, 08 Jan 2008)
Log Message:
-----------
next generation spring/dbunit tests
Modified Paths:
--------------
trunk/openutils-testing-junit/pom.xml
trunk/openutils-testing-junit-dwr/pom.xml
trunk/openutils-testing-testng/pom.xml
trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/DbUnitTestCase.java
trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/GenericsDbUnitTestCase.java
trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/SpringTestCase.java
trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/utils/DateAssert.java
trunk/openutils-testing-testng-dwr/pom.xml
Added Paths:
-----------
trunk/openutils-testing/src/main/
trunk/openutils-testing/src/main/java/
trunk/openutils-testing/src/main/java/it/
trunk/openutils-testing/src/main/java/it/openutils/
trunk/openutils-testing/src/main/java/it/openutils/testing/
trunk/openutils-testing/src/main/java/it/openutils/testing/DateAssert.java
trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitConfiguration.java
trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitUtils.java
trunk/openutils-testing/src/main/java/it/openutils/testing/RegExpTableFilter.java
trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/AbstractDbUnitTestNGSpringContextTests.java
Added: trunk/openutils-testing/src/main/java/it/openutils/testing/DateAssert.java
===================================================================
--- trunk/openutils-testing/src/main/java/it/openutils/testing/DateAssert.java (rev 0)
+++ trunk/openutils-testing/src/main/java/it/openutils/testing/DateAssert.java 2008-01-08 09:26:20 UTC (rev 518)
@@ -0,0 +1,100 @@
+package it.openutils.testing;
+
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+
+
+/**
+ * Utility methods for checking dates in unit tests.
+ * @author fgiust
+ * @version $Id$
+ */
+public final class DateAssert
+{
+
+ private static DateFormat df = new SimpleDateFormat("yyyyMMdd");
+
+ private static DateFormat dtf = new SimpleDateFormat("yyyyMMdd HH:mm");
+
+ /**
+ * Don't instantiate.
+ */
+ private DateAssert()
+ {
+ // unused
+ }
+
+ /**
+ * 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
+ {
+ Date expected;
+
+ try
+ {
+ expected = df.parse(expectedDateAsString);
+ }
+ catch (ParseException e)
+ {
+ throw new IllegalArgumentException("Unparseable date String: [" + expectedDateAsString + "]");
+ }
+
+ if (date == null)
+ {
+ throw new AssertionError("Date is null");
+ }
+ if (!date.equals(expected))
+ {
+ throw new AssertionError("Expected <" + expected + ">, actual <" + date.getTime() + ">");
+ }
+ }
+
+ /**
+ * 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 + ">");
+ }
+ }
+
+ /**
+ * 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, Calendar date) throws IllegalArgumentException
+ {
+ dateTimeEqual(expectedDateAsString, date.getTime());
+ }
+
+}
Property changes on: trunk/openutils-testing/src/main/java/it/openutils/testing/DateAssert.java
___________________________________________________________________
Name: svn:executable
+ *
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/DbUnitConfiguration.java
===================================================================
--- trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitConfiguration.java (rev 0)
+++ trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitConfiguration.java 2008-01-08 09:26:20 UTC (rev 518)
@@ -0,0 +1,34 @@
+package it.openutils.testing;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+
+/**
+ * @author fgiust
+ * @version $Id: $
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.TYPE)
+@Inherited
+@Documented
+public @interface DbUnitConfiguration {
+
+ /**
+ * The resource locations to use for loading dbunit dataset.
+ */
+ String[] datasets() default {};
+
+ String dataSource() default "";
+
+ String schema() default "";
+
+ String excludedTables() default "(^\\$(.*))"; // oracle recycle bin
+
+ boolean truncateAll() default true;
+
+}
\ No newline at end of file
Property changes on: trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitConfiguration.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/DbUnitUtils.java
===================================================================
--- trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitUtils.java (rev 0)
+++ trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitUtils.java 2008-01-08 09:26:20 UTC (rev 518)
@@ -0,0 +1,100 @@
+package it.openutils.testing;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URL;
+import java.sql.SQLException;
+
+import org.apache.commons.lang.StringUtils;
+import org.dbunit.database.IDatabaseConnection;
+import org.dbunit.dataset.DataSetException;
+import org.dbunit.dataset.FilteredDataSet;
+import org.dbunit.dataset.IDataSet;
+import org.dbunit.dataset.excel.XlsDataSet;
+import org.dbunit.dataset.xml.XmlDataSet;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * @author fgiust
+ * @version $Id: $
+ */
+public final class DbUnitUtils
+{
+
+ /**
+ * Logger.
+ */
+ private static Logger log = LoggerFactory.getLogger(DbUnitUtils.class);
+
+ /**
+ * @param connection
+ * @param tableNames
+ * @param file
+ * @param xls
+ * @throws SQLException
+ * @throws IOException
+ * @throws DataSetException
+ */
+ public static void exportDataset(IDatabaseConnection connection, String[] tableNames, File file)
+ throws SQLException, IOException, DataSetException
+ {
+ OutputStream fos = null;
+
+ try
+ {
+ IDataSet fullDataSet = connection.createDataSet();
+
+ if (tableNames != null && tableNames.length > 0)
+ {
+ fullDataSet = new FilteredDataSet(tableNames, fullDataSet);
+ }
+
+ fos = new FileOutputStream(file);
+ if (StringUtils.equalsIgnoreCase(StringUtils.substringAfterLast(file.getName(), "."), "xls"))
+ {
+ XlsDataSet.write(fullDataSet, fos);
+ }
+ else
+ {
+ XmlDataSet.write(fullDataSet, fos);
+ }
+ }
+ finally
+ {
+ connection.close();
+ fos.close();
+ }
+
+ log.debug("Dataset exported at {}", file.getAbsolutePath());
+ }
+
+ /**
+ * @param url
+ * @return
+ * @throws IOException
+ * @throws DataSetException
+ */
+ public static IDataSet loadDataset(URL url) throws IOException, DataSetException
+ {
+ if (url == null)
+ {
+ throw new IllegalArgumentException("URL is null");
+ }
+ InputStream is = url.openStream();
+ IDataSet dataSet = null;
+
+ if (is != null)
+ {
+ log.debug("loading dataset {}", url.getFile());
+ dataSet = url.getFile().endsWith(".xls") ? new XlsDataSet(is) : new XmlDataSet(is);
+ is.close();
+ }
+ return dataSet;
+ }
+
+}
Property changes on: trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitUtils.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/RegExpTableFilter.java
===================================================================
--- trunk/openutils-testing/src/main/java/it/openutils/testing/RegExpTableFilter.java (rev 0)
+++ trunk/openutils-testing/src/main/java/it/openutils/testing/RegExpTableFilter.java 2008-01-08 09:26:20 UTC (rev 518)
@@ -0,0 +1,35 @@
+package it.openutils.testing;
+
+import java.util.regex.Pattern;
+
+import org.dbunit.dataset.DataSetException;
+import org.dbunit.dataset.filter.AbstractTableFilter;
+
+
+/**
+ * @author fgiust
+ * @version $Id: $
+ */
+public class RegExpTableFilter extends AbstractTableFilter
+{
+
+ private Pattern pattern;
+
+ public RegExpTableFilter(String pattern)
+ {
+ if (pattern != null)
+ {
+ this.pattern = Pattern.compile(pattern);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean isValidName(String tableName) throws DataSetException
+ {
+ return pattern == null || pattern.matcher(tableName).matches();
+ }
+
+}
Property changes on: trunk/openutils-testing/src/main/java/it/openutils/testing/RegExpTableFilter.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified: trunk/openutils-testing-junit/pom.xml
===================================================================
--- trunk/openutils-testing-junit/pom.xml 2008-01-08 09:25:06 UTC (rev 517)
+++ trunk/openutils-testing-junit/pom.xml 2008-01-08 09:26:20 UTC (rev 518)
@@ -9,10 +9,30 @@
</parent>
<artifactId>openutils-testing-junit</artifactId>
<name>openutils test utils (junit)</name>
- <version>1.1.4-SNAPSHOT</version>
+ <version>2.0-SNAPSHOT</version>
<description>openutils test utils</description>
<dependencies>
<dependency>
+ <groupId>net.sourceforge.openutils</groupId>
+ <artifactId>openutils-testing</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-test</artifactId>
+ <version>${spring.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.2</version>
Modified: trunk/openutils-testing-junit-dwr/pom.xml
===================================================================
--- trunk/openutils-testing-junit-dwr/pom.xml 2008-01-08 09:25:06 UTC (rev 517)
+++ trunk/openutils-testing-junit-dwr/pom.xml 2008-01-08 09:26:20 UTC (rev 518)
@@ -9,10 +9,30 @@
</parent>
<artifactId>openutils-testing-junit-dwr</artifactId>
<name>openutils test utils (junit) for dwr</name>
- <version>1.2-SNAPSHOT</version>
+ <version>2.0-SNAPSHOT</version>
<description>openutils test utils for dwr</description>
<dependencies>
<dependency>
+ <groupId>net.sourceforge.openutils</groupId>
+ <artifactId>openutils-testing</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-test</artifactId>
+ <version>${spring.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.4.3</version>
Modified: trunk/openutils-testing-testng/pom.xml
===================================================================
--- trunk/openutils-testing-testng/pom.xml 2008-01-08 09:25:06 UTC (rev 517)
+++ trunk/openutils-testing-testng/pom.xml 2008-01-08 09:26:20 UTC (rev 518)
@@ -13,6 +13,26 @@
<description>openutils test utils</description>
<dependencies>
<dependency>
+ <groupId>net.sourceforge.openutils</groupId>
+ <artifactId>openutils-testing</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-test</artifactId>
+ <version>${spring.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.4.1</version>
Added: trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/AbstractDbUnitTestNGSpringContextTests.java
===================================================================
--- trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/AbstractDbUnitTestNGSpringContextTests.java (rev 0)
+++ trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/AbstractDbUnitTestNGSpringContextTests.java 2008-01-08 09:26:20 UTC (rev 518)
@@ -0,0 +1,182 @@
+package it.openutils.testing.testng;
+
+import it.openutils.testing.DbUnitConfiguration;
+import it.openutils.testing.DbUnitUtils;
+import it.openutils.testing.RegExpTableFilter;
+
+import java.io.IOException;
+import java.net.URL;
+import java.sql.SQLException;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.sql.DataSource;
+
+import org.apache.commons.lang.ArrayUtils;
+import org.apache.commons.lang.StringUtils;
+import org.dbunit.DatabaseUnitException;
+import org.dbunit.database.DatabaseConnection;
+import org.dbunit.database.DatabaseSequenceFilter;
+import org.dbunit.database.IDatabaseConnection;
+import org.dbunit.dataset.DataSetException;
+import org.dbunit.dataset.FilteredDataSet;
+import org.dbunit.dataset.IDataSet;
+import org.dbunit.dataset.filter.ITableFilter;
+import org.dbunit.dataset.filter.SequenceTableFilter;
+import org.dbunit.operation.DatabaseOperation;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.test.context.testng.AbstractTransactionalTestNGSpringContextTests;
+import org.testng.annotations.BeforeMethod;
+
+
+/**
+ * @author fgiust
+ * @version $Id: $
+ */
+public class AbstractDbUnitTestNGSpringContextTests extends AbstractTransactionalTestNGSpringContextTests
+{
+
+ /**
+ * Logger.
+ */
+ private Logger log = LoggerFactory.getLogger(AbstractDbUnitTestNGSpringContextTests.class);
+
+ /**
+ * Dataset cache.
+ */
+ private Map<String, IDataSet> datasetCache = new HashMap<String, IDataSet>();
+
+ protected static IDataSet truncateDataSet;
+
+ /**
+ * Setup the Database before running the test method.
+ * @throws Exception Any exception.
+ */
+ @SuppressWarnings("unchecked")
+ @BeforeMethod
+ protected void setUpDbUnit() throws Exception
+ {
+ final DbUnitConfiguration dbUnitConfiguration = getClass().getAnnotation(DbUnitConfiguration.class);
+ if (dbUnitConfiguration != null)
+ {
+ String[] datasets = dbUnitConfiguration.datasets();
+
+ IDatabaseConnection connection = new DatabaseConnection(getDatasource(dbUnitConfiguration.dataSource())
+ .getConnection(), dbUnitConfiguration.schema());
+
+ try
+ {
+ ITableFilter tableFilter = new RegExpTableFilter(dbUnitConfiguration.excludedTables());
+
+ if (dbUnitConfiguration.truncateAll())
+ {
+ truncateAll(connection, tableFilter);
+ }
+
+ for (String datasetFile : datasets)
+ {
+ importDataSet(createDataset(datasetFile), connection, tableFilter);
+ }
+ }
+ finally
+ {
+ connection.close();
+ }
+ }
+ }
+
+ /**
+ * @param datasetFile
+ * @return
+ * @throws IOException
+ * @throws DataSetException
+ */
+ private IDataSet createDataset(String datasetFile) throws IOException, DataSetException
+ {
+ IDataSet dataSet = datasetCache.get(datasetFile);
+ if (dataSet == null)
+ {
+ URL datasetUrl = getClass().getResource(datasetFile);
+ if (datasetUrl == null)
+ {
+ throw new IllegalArgumentException("Dataset " + datasetFile + " not found");
+ }
+ dataSet = DbUnitUtils.loadDataset(datasetUrl);
+ datasetCache.put(datasetFile, dataSet);
+ }
+ return dataSet;
+ }
+
+ private void importDataSet(IDataSet dataSet, IDatabaseConnection connection, ITableFilter tableFilter)
+ throws SQLException, DataSetException, DatabaseUnitException
+ {
+ if (dataSet == null)
+ {
+ throw new IllegalArgumentException("dataSet is null");
+ }
+ IDataSet orderedDataset = new FilteredDataSet(tableFilter, dataSet);
+
+ log.debug("Tables: {}", ArrayUtils.toString(orderedDataset.getTableNames()));
+
+ // if a sorted dataset is available, use table sequence for sorting
+ if (truncateDataSet != null)
+ {
+ ITableFilter filter = new SequenceTableFilter(truncateDataSet.getTableNames());
+ orderedDataset = new FilteredDataSet(filter, dataSet);
+ }
+
+ if (dataSet != null)
+ {
+ DatabaseOperation.INSERT.execute(connection, orderedDataset);
+ }
+
+ }
+
+ /**
+ * @param connection
+ * @param tableFilter
+ * @throws SQLException
+ * @throws DataSetException
+ * @throws DatabaseUnitException
+ */
+ private void truncateAll(IDatabaseConnection connection, ITableFilter tableFilter) throws SQLException,
+ DataSetException, DatabaseUnitException
+ {
+ if (truncateDataSet == null)
+ {
+ log.debug("Generating sorted dataset for initial cleanup");
+ IDataSet unsortedDataSet = connection.createDataSet();
+
+ ITableFilter filter = new DatabaseSequenceFilter(connection, new FilteredDataSet(
+ tableFilter,
+ unsortedDataSet).getTableNames());
+ truncateDataSet = new FilteredDataSet(tableFilter, new FilteredDataSet(filter, unsortedDataSet));
+ log.debug("Sorted dataset generated");
+ }
+
+ log.debug("Tables truncateDataSet: {}", ArrayUtils.toString(truncateDataSet.getTableNames()));
+ if (truncateDataSet != null)
+ {
+ DatabaseOperation.DELETE_ALL.execute(connection, truncateDataSet);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ protected DataSource getDatasource(String name)
+ {
+ if (StringUtils.isEmpty(name))
+ {
+ Map<String, DataSource> dsMap = applicationContext.getBeansOfType(DataSource.class);
+ if (dsMap == null || dsMap.size() != 1)
+ {
+ throw new RuntimeException(
+ "Unable to find a datasource in spring applicationContext, please specify the datasource bean name "
+ + "using the \"datasource\" attribute of @DbUnitConfiguration");
+ }
+ return dsMap.values().iterator().next();
+ }
+ return (DataSource) applicationContext.getBean(name);
+ }
+
+}
Property changes on: trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/AbstractDbUnitTestNGSpringContextTests.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified: trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/DbUnitTestCase.java
===================================================================
--- trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/DbUnitTestCase.java 2008-01-08 09:25:06 UTC (rev 517)
+++ trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/DbUnitTestCase.java 2008-01-08 09:26:20 UTC (rev 518)
@@ -54,8 +54,10 @@
/**
* @author fgiust
* @version $Id$
+ * @deprecated use {@link AbstractDbUnitTestNGSpringContextTests}
*/
@Test
+@Deprecated
public class DbUnitTestCase extends SpringTestCase
{
@@ -134,8 +136,7 @@
}
this.sessionFactory = sfbeans.get(sfbeans.keySet().iterator().next());
- TransactionSynchronizationManager.bindResource(this.sessionFactory, new SessionHolder(this
- .sessionFactory
+ TransactionSynchronizationManager.bindResource(this.sessionFactory, new SessionHolder(this.sessionFactory
.openSession()));
}
@@ -188,7 +189,7 @@
{
// close open hibernate sessions, mimic the OpenSessionInViewFilter
// close open hibernate sessions, mimic the OpenSessionInViewFilter
- if (TransactionSynchronizationManager.hasResource(this.sessionFactory))
+ if (TransactionSynchronizationManager.hasResource(this.sessionFactory))
{
TransactionSynchronizationManager.unbindResource(this.sessionFactory);
}
Modified: trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/GenericsDbUnitTestCase.java
===================================================================
--- trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/GenericsDbUnitTestCase.java 2008-01-08 09:25:06 UTC (rev 517)
+++ trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/GenericsDbUnitTestCase.java 2008-01-08 09:26:20 UTC (rev 518)
@@ -20,6 +20,7 @@
import org.apache.commons.lang.ClassUtils;
import org.apache.commons.lang.StringUtils;
import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
/**
@@ -29,7 +30,10 @@
* from Spring is made available through the <code>instance</code> protected field.
* @author fgiust
* @version $Id$
+ * @deprecated use {@link AbstractDbUnitTestNGSpringContextTests}
*/
+@Test
+@Deprecated
public class GenericsDbUnitTestCase<D> extends DbUnitTestCase
{
Modified: trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/SpringTestCase.java
===================================================================
--- trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/SpringTestCase.java 2008-01-08 09:25:06 UTC (rev 517)
+++ trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/SpringTestCase.java 2008-01-08 09:26:20 UTC (rev 518)
@@ -28,8 +28,10 @@
* Base class for running spring-based tests.
* @author fgiust
* @version $Revision $ ($Author $)
+ * @deprecated {@link org.springframework.test.context.testng.AbstractTestNGSpringContextTests}
*/
@Test
+@Deprecated
public abstract class SpringTestCase
{
Modified: trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/utils/DateAssert.java
===================================================================
--- trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/utils/DateAssert.java 2008-01-08 09:25:06 UTC (rev 517)
+++ trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/utils/DateAssert.java 2008-01-08 09:26:20 UTC (rev 518)
@@ -16,7 +16,9 @@
* Utility methods for checking dates in unit tests.
* @author fgiust
* @version $Id$
+ * @deprecated use {@link it.openutils.testing.DateAssert}
*/
+@Deprecated
public final class DateAssert
{
Modified: trunk/openutils-testing-testng-dwr/pom.xml
===================================================================
--- trunk/openutils-testing-testng-dwr/pom.xml 2008-01-08 09:25:06 UTC (rev 517)
+++ trunk/openutils-testing-testng-dwr/pom.xml 2008-01-08 09:26:20 UTC (rev 518)
@@ -13,6 +13,26 @@
<description>openutils test utils for dwr</description>
<dependencies>
<dependency>
+ <groupId>net.sourceforge.openutils</groupId>
+ <artifactId>openutils-testing</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-test</artifactId>
+ <version>${spring.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.4.3</version>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fg...@us...> - 2008-01-09 22:33:43
|
Revision: 523
http://openutils.svn.sourceforge.net/openutils/?rev=523&view=rev
Author: fgiust
Date: 2008-01-09 14:33:43 -0800 (Wed, 09 Jan 2008)
Log Message:
-----------
support for multiple databases
Modified Paths:
--------------
trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitConfiguration.java
trunk/openutils-testing-testng/pom.xml
trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/AbstractDbUnitTestNGSpringContextTests.java
Added Paths:
-----------
trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitExecution.java
trunk/openutils-testing-testng/src/test/
trunk/openutils-testing-testng/src/test/java/
trunk/openutils-testing-testng/src/test/java/it/
trunk/openutils-testing-testng/src/test/java/it/openutils/
trunk/openutils-testing-testng/src/test/java/it/openutils/testing/
trunk/openutils-testing-testng/src/test/java/it/openutils/testing/testng/
trunk/openutils-testing-testng/src/test/java/it/openutils/testing/testng/MultipleDatasourceDbUnitTest.java
trunk/openutils-testing-testng/src/test/java/it/openutils/testing/testng/SingleDatasourceDbUnitTest.java
trunk/openutils-testing-testng/src/test/resources/
trunk/openutils-testing-testng/src/test/resources/db1-load.xml
trunk/openutils-testing-testng/src/test/resources/db2-load.xml
trunk/openutils-testing-testng/src/test/resources/log4j.dtd
trunk/openutils-testing-testng/src/test/resources/log4j.xml
trunk/openutils-testing-testng/src/test/resources/spring-tests.xml
Property Changed:
----------------
trunk/openutils-testing-testng/
Modified: trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitConfiguration.java
===================================================================
--- trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitConfiguration.java 2008-01-08 11:50:27 UTC (rev 522)
+++ trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitConfiguration.java 2008-01-09 22:33:43 UTC (rev 523)
@@ -18,17 +18,6 @@
@Documented
public @interface DbUnitConfiguration {
- /**
- * The resource locations to use for loading dbunit dataset.
- */
- String[] datasets() default {};
+ DbUnitExecution[] dbUnitExecutions() default {};
- String dataSource() default "";
-
- String schema() default "";
-
- String excludedTables() default "(^\\$(.*))"; // oracle recycle bin
-
- boolean truncateAll() default true;
-
}
\ No newline at end of file
Added: trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitExecution.java
===================================================================
--- trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitExecution.java (rev 0)
+++ trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitExecution.java 2008-01-09 22:33:43 UTC (rev 523)
@@ -0,0 +1,34 @@
+package it.openutils.testing;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+
+/**
+ * @author fgiust
+ * @version $Id: $
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.TYPE)
+@Inherited
+@Documented
+public @interface DbUnitExecution {
+
+ /**
+ * The resource locations to use for loading dbunit dataset.
+ */
+ String[] datasets() default {};
+
+ String dataSource() default "";
+
+ String schema() default "";
+
+ String excludedTables() default "(^\\$(.*))"; // oracle recycle bin
+
+ boolean truncateAll() default true;
+
+}
\ No newline at end of file
Property changes on: trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitExecution.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Property changes on: trunk/openutils-testing-testng
___________________________________________________________________
Name: svn:ignore
- .checkstyle
target
.settings
.classpath
.project
+ .checkstyle
target
.settings
.classpath
.project
test-output
temp-testng-customsuite.xml
Modified: trunk/openutils-testing-testng/pom.xml
===================================================================
--- trunk/openutils-testing-testng/pom.xml 2008-01-08 11:50:27 UTC (rev 522)
+++ trunk/openutils-testing-testng/pom.xml 2008-01-09 22:33:43 UTC (rev 523)
@@ -129,6 +129,44 @@
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>org.apache.derby</groupId>
+ <artifactId>derby</artifactId>
+ <version>10.2.2.0</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-dbcp</groupId>
+ <artifactId>commons-dbcp</artifactId>
+ <version>1.2.1</version>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <artifactId>xerces</artifactId>
+ <groupId>xerces</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>xml-apis</artifactId>
+ <groupId>xml-apis</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>commons-logging</artifactId>
+ <groupId>commons-logging</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-jdbc</artifactId>
+ <version>${spring.version}</version>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
</dependencies>
<properties>
<spring.version>2.5</spring.version>
Modified: trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/AbstractDbUnitTestNGSpringContextTests.java
===================================================================
--- trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/AbstractDbUnitTestNGSpringContextTests.java 2008-01-08 11:50:27 UTC (rev 522)
+++ trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/AbstractDbUnitTestNGSpringContextTests.java 2008-01-09 22:33:43 UTC (rev 523)
@@ -1,6 +1,7 @@
package it.openutils.testing.testng;
import it.openutils.testing.DbUnitConfiguration;
+import it.openutils.testing.DbUnitExecution;
import it.openutils.testing.DbUnitUtils;
import it.openutils.testing.RegExpTableFilter;
@@ -26,7 +27,7 @@
import org.dbunit.operation.DatabaseOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.test.context.testng.AbstractTransactionalTestNGSpringContextTests;
+import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
import org.testng.annotations.BeforeMethod;
@@ -34,7 +35,7 @@
* @author fgiust
* @version $Id: $
*/
-public class AbstractDbUnitTestNGSpringContextTests extends AbstractTransactionalTestNGSpringContextTests
+public class AbstractDbUnitTestNGSpringContextTests extends AbstractTestNGSpringContextTests
{
/**
@@ -47,7 +48,11 @@
*/
private Map<String, IDataSet> datasetCache = new HashMap<String, IDataSet>();
- protected static IDataSet truncateDataSet;
+ /**
+ * Truncate dataset cache. This is kept as a static attribute since the creation of the dataset is very expensive
+ * and it doesn't change across tests.
+ */
+ protected static Map<String, IDataSet> truncateDataSetCache = new HashMap<String, IDataSet>();
/**
* Setup the Database before running the test method.
@@ -57,26 +62,40 @@
@BeforeMethod
protected void setUpDbUnit() throws Exception
{
- final DbUnitConfiguration dbUnitConfiguration = getClass().getAnnotation(DbUnitConfiguration.class);
- if (dbUnitConfiguration != null)
+ DbUnitExecution singleDbUnitExecution = getClass().getAnnotation(DbUnitExecution.class);
+
+ DbUnitExecution[] executions;
+ if (singleDbUnitExecution != null)
{
- String[] datasets = dbUnitConfiguration.datasets();
+ executions = new DbUnitExecution[]{singleDbUnitExecution };
+ }
+ else
+ {
+ DbUnitConfiguration dbUnitConfiguration = getClass().getAnnotation(DbUnitConfiguration.class);
+ executions = dbUnitConfiguration.dbUnitExecutions();
+ }
- IDatabaseConnection connection = new DatabaseConnection(getDatasource(dbUnitConfiguration.dataSource())
- .getConnection(), dbUnitConfiguration.schema());
+ for (DbUnitExecution dbUnitExecution : executions)
+ {
+ String[] datasets = dbUnitExecution.datasets();
+ String dataSourceName = dbUnitExecution.dataSource();
+ IDatabaseConnection connection = new DatabaseConnection(
+ getDatasource(dataSourceName).getConnection(),
+ dbUnitExecution.schema());
+
try
{
- ITableFilter tableFilter = new RegExpTableFilter(dbUnitConfiguration.excludedTables());
+ ITableFilter tableFilter = new RegExpTableFilter(dbUnitExecution.excludedTables());
- if (dbUnitConfiguration.truncateAll())
+ if (dbUnitExecution.truncateAll())
{
- truncateAll(connection, tableFilter);
+ truncateAll(connection, tableFilter, dataSourceName);
}
for (String datasetFile : datasets)
{
- importDataSet(createDataset(datasetFile), connection, tableFilter);
+ importDataSet(createDataset(datasetFile), connection, tableFilter, dataSourceName);
}
}
finally
@@ -108,9 +127,10 @@
return dataSet;
}
- private void importDataSet(IDataSet dataSet, IDatabaseConnection connection, ITableFilter tableFilter)
- throws SQLException, DataSetException, DatabaseUnitException
+ private void importDataSet(IDataSet dataSet, IDatabaseConnection connection, ITableFilter tableFilter,
+ String dataSourceName) throws SQLException, DataSetException, DatabaseUnitException
{
+
if (dataSet == null)
{
throw new IllegalArgumentException("dataSet is null");
@@ -120,6 +140,7 @@
log.debug("Tables: {}", ArrayUtils.toString(orderedDataset.getTableNames()));
// if a sorted dataset is available, use table sequence for sorting
+ IDataSet truncateDataSet = getTruncateDataset(dataSourceName, connection.getSchema());
if (truncateDataSet != null)
{
ITableFilter filter = new SequenceTableFilter(truncateDataSet.getTableNames());
@@ -140,9 +161,10 @@
* @throws DataSetException
* @throws DatabaseUnitException
*/
- private void truncateAll(IDatabaseConnection connection, ITableFilter tableFilter) throws SQLException,
- DataSetException, DatabaseUnitException
+ private void truncateAll(IDatabaseConnection connection, ITableFilter tableFilter, String dataSourceName)
+ throws SQLException, DataSetException, DatabaseUnitException
{
+ IDataSet truncateDataSet = getTruncateDataset(dataSourceName, connection.getSchema());
if (truncateDataSet == null)
{
log.debug("Generating sorted dataset for initial cleanup");
@@ -152,6 +174,7 @@
tableFilter,
unsortedDataSet).getTableNames());
truncateDataSet = new FilteredDataSet(tableFilter, new FilteredDataSet(filter, unsortedDataSet));
+ storeTruncateDataset(dataSourceName, connection.getSchema(), truncateDataSet);
log.debug("Sorted dataset generated");
}
@@ -162,6 +185,16 @@
}
}
+ private IDataSet getTruncateDataset(String datasourceName, String schema)
+ {
+ return truncateDataSetCache.get(datasourceName + "_" + StringUtils.defaultString(schema));
+ }
+
+ private IDataSet storeTruncateDataset(String datasourceName, String schema, IDataSet dataset)
+ {
+ return truncateDataSetCache.put(datasourceName + "_" + StringUtils.defaultString(schema), dataset);
+ }
+
@SuppressWarnings("unchecked")
protected DataSource getDatasource(String name)
{
Added: trunk/openutils-testing-testng/src/test/java/it/openutils/testing/testng/MultipleDatasourceDbUnitTest.java
===================================================================
--- trunk/openutils-testing-testng/src/test/java/it/openutils/testing/testng/MultipleDatasourceDbUnitTest.java (rev 0)
+++ trunk/openutils-testing-testng/src/test/java/it/openutils/testing/testng/MultipleDatasourceDbUnitTest.java 2008-01-09 22:33:43 UTC (rev 523)
@@ -0,0 +1,27 @@
+package it.openutils.testing.testng;
+
+import it.openutils.testing.DbUnitConfiguration;
+import it.openutils.testing.DbUnitExecution;
+
+import org.springframework.test.context.ContextConfiguration;
+import org.testng.annotations.Test;
+
+
+/**
+ * @author fgiust
+ * @version $Id: $
+ */
+@ContextConfiguration(locations = {"/spring-tests.xml" })
+@DbUnitConfiguration(dbUnitExecutions = {
+ @DbUnitExecution(datasets = {"/db1-load.xml" }, dataSource = "dataSource1"),
+ @DbUnitExecution(datasets = {"/db2-load.xml" }, dataSource = "dataSource2") })
+public class MultipleDatasourceDbUnitTest extends AbstractDbUnitTestNGSpringContextTests
+{
+
+ @Test
+ public void testLoad() throws Exception
+ {
+ // do nothing
+ }
+
+}
Property changes on: trunk/openutils-testing-testng/src/test/java/it/openutils/testing/testng/MultipleDatasourceDbUnitTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: trunk/openutils-testing-testng/src/test/java/it/openutils/testing/testng/SingleDatasourceDbUnitTest.java
===================================================================
--- trunk/openutils-testing-testng/src/test/java/it/openutils/testing/testng/SingleDatasourceDbUnitTest.java (rev 0)
+++ trunk/openutils-testing-testng/src/test/java/it/openutils/testing/testng/SingleDatasourceDbUnitTest.java 2008-01-09 22:33:43 UTC (rev 523)
@@ -0,0 +1,31 @@
+package it.openutils.testing.testng;
+
+import it.openutils.testing.DbUnitExecution;
+
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.TestExecutionListeners;
+import org.springframework.test.context.transaction.TransactionConfiguration;
+import org.springframework.test.context.transaction.TransactionalTestExecutionListener;
+import org.springframework.transaction.annotation.Transactional;
+import org.testng.annotations.Test;
+
+
+/**
+ * @author fgiust
+ * @version $Id: $
+ */
+@ContextConfiguration(locations = {"/spring-tests.xml" })
+@DbUnitExecution(datasets = {"/db1-load.xml" }, dataSource = "dataSource1")
+@TestExecutionListeners({TransactionalTestExecutionListener.class })
+@Transactional
+@TransactionConfiguration(transactionManager = "transactionManager1")
+public class SingleDatasourceDbUnitTest extends AbstractDbUnitTestNGSpringContextTests
+{
+
+ @Test
+ public void testLoad() throws Exception
+ {
+ // do nothing
+ }
+
+}
Property changes on: trunk/openutils-testing-testng/src/test/java/it/openutils/testing/testng/SingleDatasourceDbUnitTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: trunk/openutils-testing-testng/src/test/resources/db1-load.xml
===================================================================
--- trunk/openutils-testing-testng/src/test/resources/db1-load.xml (rev 0)
+++ trunk/openutils-testing-testng/src/test/resources/db1-load.xml 2008-01-09 22:33:43 UTC (rev 523)
@@ -0,0 +1,8 @@
+<dataset>
+ <table name="ONE">
+ <column>ONE</column>
+ <row>
+ <value>1</value>
+ </row>
+ </table>
+</dataset>
Property changes on: trunk/openutils-testing-testng/src/test/resources/db1-load.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: trunk/openutils-testing-testng/src/test/resources/db2-load.xml
===================================================================
--- trunk/openutils-testing-testng/src/test/resources/db2-load.xml (rev 0)
+++ trunk/openutils-testing-testng/src/test/resources/db2-load.xml 2008-01-09 22:33:43 UTC (rev 523)
@@ -0,0 +1,8 @@
+<dataset>
+ <table name="ONE">
+ <column>TWO</column>
+ <row>
+ <value>2</value>
+ </row>
+ </table>
+</dataset>
Property changes on: trunk/openutils-testing-testng/src/test/resources/db2-load.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: trunk/openutils-testing-testng/src/test/resources/log4j.dtd
===================================================================
--- trunk/openutils-testing-testng/src/test/resources/log4j.dtd (rev 0)
+++ trunk/openutils-testing-testng/src/test/resources/log4j.dtd 2008-01-09 22:33:43 UTC (rev 523)
@@ -0,0 +1,166 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<!-- Authors: Chris Taylor, Ceki Gulcu. -->
+
+<!-- Version: 1.2 -->
+
+<!-- A configuration element consists of optional renderer
+elements,appender elements, categories and an optional root
+element. -->
+
+<!ELEMENT log4j:configuration (renderer*, appender*,(category|logger)*,root?,
+ categoryFactory?)>
+
+<!-- The "threshold" attribute takes a level value such that all -->
+<!-- logging statements with a level equal or below this value are -->
+<!-- disabled. -->
+
+<!-- Setting the "debug" enable the printing of internal log4j logging -->
+<!-- statements. -->
+
+<!-- By default, debug attribute is "null", meaning that we not do touch -->
+<!-- internal log4j logging settings. The "null" value for the threshold -->
+<!-- attribute can be misleading. The threshold field of a repository -->
+<!-- cannot be set to null. The "null" value for the threshold attribute -->
+<!-- simply means don't touch the threshold field, the threshold field -->
+<!-- keeps its old value. -->
+
+<!ATTLIST log4j:configuration
+ xmlns:log4j CDATA #FIXED "http://jakarta.apache.org/log4j/"
+ threshold (all|debug|info|warn|error|fatal|off|null) "null"
+ debug (true|false|null) "null"
+>
+
+<!-- renderer elements allow the user to customize the conversion of -->
+<!-- message objects to String. -->
+
+<!ELEMENT renderer EMPTY>
+<!ATTLIST renderer
+ renderedClass CDATA #REQUIRED
+ renderingClass CDATA #REQUIRED
+>
+
+<!-- Appenders must have a name and a class. -->
+<!-- Appenders may contain an error handler, a layout, optional parameters -->
+<!-- and filters. They may also reference (or include) other appenders. -->
+<!ELEMENT appender (errorHandler?, param*, layout?, filter*, appender-ref*)>
+<!ATTLIST appender
+ name ID #REQUIRED
+ class CDATA #REQUIRED
+>
+
+<!ELEMENT layout (param*)>
+<!ATTLIST layout
+ class CDATA #REQUIRED
+>
+
+<!ELEMENT filter (param*)>
+<!ATTLIST filter
+ class CDATA #REQUIRED
+>
+
+<!-- ErrorHandlers can be of any class. They can admit any number of -->
+<!-- parameters. -->
+
+<!ELEMENT errorHandler (param*, root-ref?, logger-ref*, appender-ref?)>
+<!ATTLIST errorHandler
+ class CDATA #REQUIRED
+>
+
+<!ELEMENT root-ref EMPTY>
+
+<!ELEMENT logger-ref EMPTY>
+<!ATTLIST logger-ref
+ ref IDREF #REQUIRED
+>
+
+<!ELEMENT param EMPTY>
+<!ATTLIST param
+ name CDATA #REQUIRED
+ value CDATA #REQUIRED
+>
+
+
+<!-- The priority class is org.apache.log4j.Level by default -->
+<!ELEMENT priority (param*)>
+<!ATTLIST priority
+ class CDATA #IMPLIED
+ value CDATA #REQUIRED
+>
+
+<!-- The level class is org.apache.log4j.Level by default -->
+<!ELEMENT level (param*)>
+<!ATTLIST level
+ class CDATA #IMPLIED
+ value CDATA #REQUIRED
+>
+
+
+<!-- If no level element is specified, then the configurator MUST not -->
+<!-- touch the level of the named category. -->
+<!ELEMENT category (param*,(priority|level)?,appender-ref*)>
+<!ATTLIST category
+ class CDATA #IMPLIED
+ name CDATA #REQUIRED
+ additivity (true|false) "true"
+>
+
+<!-- If no level element is specified, then the configurator MUST not -->
+<!-- touch the level of the named logger. -->
+<!ELEMENT logger (level?,appender-ref*)>
+<!ATTLIST logger
+ name ID #REQUIRED
+ additivity (true|false) "true"
+>
+
+
+<!ELEMENT categoryFactory (param*)>
+<!ATTLIST categoryFactory
+ class CDATA #REQUIRED>
+
+<!ELEMENT appender-ref EMPTY>
+<!ATTLIST appender-ref
+ ref IDREF #REQUIRED
+>
+
+<!-- If no priority element is specified, then the configurator MUST not -->
+<!-- touch the priority of root. -->
+<!-- The root category always exists and cannot be subclassed. -->
+<!ELEMENT root (param*, (priority|level)?, appender-ref*)>
+
+
+<!-- ==================================================================== -->
+<!-- A logging event -->
+<!-- ==================================================================== -->
+<!ELEMENT log4j:eventSet (log4j:event*)>
+<!ATTLIST log4j:eventSet
+ xmlns:log4j CDATA #FIXED "http://jakarta.apache.org/log4j/"
+ version (1.1|1.2) "1.2"
+ includesLocationInfo (true|false) "true"
+>
+
+
+
+<!ELEMENT log4j:event (log4j:message, log4j:NDC?, log4j:throwable?,
+ log4j:locationInfo?) >
+
+<!-- The timestamp format is application dependent. -->
+<!ATTLIST log4j:event
+ logger CDATA #REQUIRED
+ level CDATA #REQUIRED
+ thread CDATA #REQUIRED
+ timestamp CDATA #REQUIRED
+>
+
+<!ELEMENT log4j:message (#PCDATA)>
+<!ELEMENT log4j:NDC (#PCDATA)>
+
+<!ELEMENT log4j:throwable (#PCDATA)>
+
+<!ELEMENT log4j:locationInfo EMPTY>
+<!ATTLIST log4j:locationInfo
+ class CDATA #REQUIRED
+ method CDATA #REQUIRED
+ file CDATA #REQUIRED
+ line CDATA #REQUIRED
+>
Property changes on: trunk/openutils-testing-testng/src/test/resources/log4j.dtd
___________________________________________________________________
Name: svn:mime-type
+ text/xml
Name: svn:eol-style
+ native
Added: trunk/openutils-testing-testng/src/test/resources/log4j.xml
===================================================================
--- trunk/openutils-testing-testng/src/test/resources/log4j.xml (rev 0)
+++ trunk/openutils-testing-testng/src/test/resources/log4j.xml 2008-01-09 22:33:43 UTC (rev 523)
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+<log4j:configuration>
+ <!-- log4j test configuration -->
+ <appender name="test-appender" class="org.apache.log4j.ConsoleAppender">
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%-5p %c.%M(%C{1}.java:%L) %m%n" />
+ </layout>
+ </appender>
+ <category name="org">
+ <priority value="WARN" />
+ </category>
+ <category name="com">
+ <priority value="WARN" />
+ </category>
+ <category name="net">
+ <priority value="WARN" />
+ </category>
+ <category name="info">
+ <priority value="WARN" />
+ </category>
+ <category name="it">
+ <priority value="WARN" />
+ </category>
+ <root>
+ <priority value="debug" />
+ <appender-ref ref="test-appender" />
+ </root>
+</log4j:configuration>
\ No newline at end of file
Property changes on: trunk/openutils-testing-testng/src/test/resources/log4j.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: trunk/openutils-testing-testng/src/test/resources/spring-tests.xml
===================================================================
--- trunk/openutils-testing-testng/src/test/resources/spring-tests.xml (rev 0)
+++ trunk/openutils-testing-testng/src/test/resources/spring-tests.xml 2008-01-09 22:33:43 UTC (rev 523)
@@ -0,0 +1,23 @@
+<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:util="http://www.springframework.org/schema/util"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+ http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd">
+ <bean id="dataSource1" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
+ <property name="driverClassName" value="org.apache.derby.jdbc.EmbeddedDriver" />
+ <property name="url" value="jdbc:derby:target/test-db1;create=true" />
+ <property name="username" value="test" />
+ <property name="password" value="test" />
+ </bean>
+ <bean id="transactionManager1" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
+ <property name="dataSource" ref="dataSource1" />
+ </bean>
+ <bean id="dataSource2" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
+ <property name="driverClassName" value="org.apache.derby.jdbc.EmbeddedDriver" />
+ <property name="url" value="jdbc:derby:target/test-db2;create=true" />
+ <property name="username" value="test" />
+ <property name="password" value="test" />
+ </bean>
+ <bean id="transactionManager2" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
+ <property name="dataSource" ref="dataSource2" />
+ </bean>
+</beans>
\ No newline at end of file
Property changes on: trunk/openutils-testing-testng/src/test/resources/spring-tests.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-09 23:06:47
|
Revision: 524
http://openutils.svn.sourceforge.net/openutils/?rev=524&view=rev
Author: fgiust
Date: 2008-01-09 15:06:51 -0800 (Wed, 09 Jan 2008)
Log Message:
-----------
cleaning up and testing
Modified Paths:
--------------
trunk/openutils-testing/src/main/java/it/openutils/testing/RegExpTableFilter.java
trunk/openutils-testing-testng/pom.xml
trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/AbstractDbUnitTestNGSpringContextTests.java
Modified: trunk/openutils-testing/src/main/java/it/openutils/testing/RegExpTableFilter.java
===================================================================
--- trunk/openutils-testing/src/main/java/it/openutils/testing/RegExpTableFilter.java 2008-01-09 22:33:43 UTC (rev 523)
+++ trunk/openutils-testing/src/main/java/it/openutils/testing/RegExpTableFilter.java 2008-01-09 23:06:51 UTC (rev 524)
@@ -29,7 +29,7 @@
@Override
public boolean isValidName(String tableName) throws DataSetException
{
- return pattern == null || pattern.matcher(tableName).matches();
+ return pattern == null || !pattern.matcher(tableName).matches();
}
}
Modified: trunk/openutils-testing-testng/pom.xml
===================================================================
--- trunk/openutils-testing-testng/pom.xml 2008-01-09 22:33:43 UTC (rev 523)
+++ trunk/openutils-testing-testng/pom.xml 2008-01-09 23:06:51 UTC (rev 524)
@@ -11,6 +11,17 @@
<name>openutils test utils (testng)</name>
<version>2.0-SNAPSHOT</version>
<description>openutils test utils</description>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.3.1</version>
+ <configuration>
+ <forkMode>once</forkMode>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
<dependencies>
<dependency>
<groupId>net.sourceforge.openutils</groupId>
Modified: trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/AbstractDbUnitTestNGSpringContextTests.java
===================================================================
--- trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/AbstractDbUnitTestNGSpringContextTests.java 2008-01-09 22:33:43 UTC (rev 523)
+++ trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/AbstractDbUnitTestNGSpringContextTests.java 2008-01-09 23:06:51 UTC (rev 524)
@@ -41,7 +41,7 @@
/**
* Logger.
*/
- private Logger log = LoggerFactory.getLogger(AbstractDbUnitTestNGSpringContextTests.class);
+ private Logger log = LoggerFactory.getLogger(getClass());
/**
* Dataset cache.
@@ -79,10 +79,15 @@
{
String[] datasets = dbUnitExecution.datasets();
String dataSourceName = dbUnitExecution.dataSource();
+ String schema = dbUnitExecution.schema();
+ if (StringUtils.isEmpty(schema))
+ {
+ schema = null;
+ }
IDatabaseConnection connection = new DatabaseConnection(
getDatasource(dataSourceName).getConnection(),
- dbUnitExecution.schema());
+ schema);
try
{
@@ -170,6 +175,8 @@
log.debug("Generating sorted dataset for initial cleanup");
IDataSet unsortedDataSet = connection.createDataSet();
+ log.debug("Unfiltered truncateDataSet: {}", ArrayUtils.toString(unsortedDataSet.getTableNames()));
+
ITableFilter filter = new DatabaseSequenceFilter(connection, new FilteredDataSet(
tableFilter,
unsortedDataSet).getTableNames());
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fg...@us...> - 2008-01-12 10:46:19
|
Revision: 525
http://openutils.svn.sourceforge.net/openutils/?rev=525&view=rev
Author: fgiust
Date: 2008-01-12 02:46:12 -0800 (Sat, 12 Jan 2008)
Log Message:
-----------
cleaning up
Modified Paths:
--------------
trunk/openutils-testing/pom.xml
trunk/openutils-testing/src/main/java/it/openutils/testing/DateAssert.java
trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitConfiguration.java
trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitExecution.java
trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitUtils.java
trunk/openutils-testing/src/main/java/it/openutils/testing/RegExpTableFilter.java
trunk/openutils-testing-junit/pom.xml
trunk/openutils-testing-junit/src/main/java/it/openutils/testing/junit/DbUnitTestCase.java
trunk/openutils-testing-junit/src/main/java/it/openutils/testing/junit/GenericsDbUnitTestCase.java
trunk/openutils-testing-junit/src/main/java/it/openutils/testing/junit/SpringTestCase.java
trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/AbstractDbUnitTestNGSpringContextTests.java
trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/DbUnitTestCase.java
trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/GenericsDbUnitTestCase.java
trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/SpringTestCase.java
trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/utils/DateAssert.java
trunk/openutils-testing-testng/src/test/java/it/openutils/testing/testng/MultipleDatasourceDbUnitTest.java
trunk/openutils-testing-testng/src/test/java/it/openutils/testing/testng/SingleDatasourceDbUnitTest.java
Added Paths:
-----------
trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitTestContext.java
trunk/openutils-testing-junit/src/main/java/it/openutils/testing/junit/AbstractDbUnitJunitSpringContextTests.java
Modified: trunk/openutils-testing/pom.xml
===================================================================
--- trunk/openutils-testing/pom.xml 2008-01-09 23:06:51 UTC (rev 524)
+++ trunk/openutils-testing/pom.xml 2008-01-12 10:46:12 UTC (rev 525)
@@ -28,6 +28,17 @@
<version>2.3</version>
</dependency>
<dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ <version>${spring.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
<groupId>org.dbunit</groupId>
<artifactId>dbunit</artifactId>
<version>2.2</version>
Modified: trunk/openutils-testing/src/main/java/it/openutils/testing/DateAssert.java
===================================================================
--- trunk/openutils-testing/src/main/java/it/openutils/testing/DateAssert.java 2008-01-09 23:06:51 UTC (rev 524)
+++ trunk/openutils-testing/src/main/java/it/openutils/testing/DateAssert.java 2008-01-12 10:46:12 UTC (rev 525)
@@ -1,3 +1,18 @@
+/*
+ * 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;
import java.text.DateFormat;
Modified: trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitConfiguration.java
===================================================================
--- trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitConfiguration.java 2008-01-09 23:06:51 UTC (rev 524)
+++ trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitConfiguration.java 2008-01-12 10:46:12 UTC (rev 525)
@@ -1,3 +1,18 @@
+/*
+ * 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;
import java.lang.annotation.Documented;
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-09 23:06:51 UTC (rev 524)
+++ trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitExecution.java 2008-01-12 10:46:12 UTC (rev 525)
@@ -1,3 +1,18 @@
+/*
+ * 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;
import java.lang.annotation.Documented;
@@ -7,7 +22,9 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
+import org.dbunit.operation.DatabaseOperation;
+
/**
* @author fgiust
* @version $Id: $
@@ -31,4 +48,8 @@
boolean truncateAll() default true;
+ Class< ? extends DatabaseOperation> truncateOperation() default org.dbunit.operation.TruncateTableOperation.class;
+
+ Class< ? extends DatabaseOperation> insertOperation() default org.dbunit.operation.InsertOperation.class;
+
}
\ No newline at end of file
Added: trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitTestContext.java
===================================================================
--- trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitTestContext.java (rev 0)
+++ trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitTestContext.java 2008-01-12 10:46:12 UTC (rev 525)
@@ -0,0 +1,246 @@
+/*
+ * 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;
+
+import java.io.IOException;
+import java.net.URL;
+import java.sql.SQLException;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.sql.DataSource;
+
+import org.apache.commons.lang.ArrayUtils;
+import org.apache.commons.lang.StringUtils;
+import org.dbunit.DatabaseUnitException;
+import org.dbunit.database.DatabaseConnection;
+import org.dbunit.database.DatabaseSequenceFilter;
+import org.dbunit.database.IDatabaseConnection;
+import org.dbunit.dataset.DataSetException;
+import org.dbunit.dataset.FilteredDataSet;
+import org.dbunit.dataset.IDataSet;
+import org.dbunit.dataset.filter.ITableFilter;
+import org.dbunit.dataset.filter.SequenceTableFilter;
+import org.dbunit.operation.DatabaseOperation;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.context.ApplicationContext;
+
+
+/**
+ * @author fgiust
+ * @version $Id: $
+ */
+public class DbUnitTestContext
+{
+
+ /**
+ * Logger.
+ */
+ private static Logger log = LoggerFactory.getLogger(DbUnitTestContext.class);
+
+ private Object testcase;
+
+ private ApplicationContext applicationContext;
+
+ /**
+ * Dataset cache.
+ */
+ private Map<String, IDataSet> datasetCache = new HashMap<String, IDataSet>();
+
+ /**
+ * Truncate dataset cache. This is kept as a static attribute since the creation of the dataset is very expensive
+ * and it doesn't change across tests.
+ */
+ protected static Map<String, IDataSet> truncateDataSetCache = new HashMap<String, IDataSet>();
+
+ public DbUnitTestContext(Object testcase, ApplicationContext applicationContext)
+ {
+ this.testcase = testcase;
+ this.applicationContext = applicationContext;
+ }
+
+ /**
+ * Setup the Database before running the test method.
+ * @throws Exception Any exception.
+ */
+ @SuppressWarnings("unchecked")
+ public void setUpDbUnit() throws Exception
+ {
+ DbUnitExecution singleDbUnitExecution = testcase.getClass().getAnnotation(DbUnitExecution.class);
+
+ DbUnitExecution[] executions;
+ if (singleDbUnitExecution != null)
+ {
+ executions = new DbUnitExecution[]{singleDbUnitExecution };
+ }
+ else
+ {
+ DbUnitConfiguration dbUnitConfiguration = testcase.getClass().getAnnotation(DbUnitConfiguration.class);
+ executions = dbUnitConfiguration.dbUnitExecutions();
+ }
+
+ for (DbUnitExecution dbUnitExecution : executions)
+ {
+ String[] datasets = dbUnitExecution.datasets();
+ String dataSourceName = dbUnitExecution.dataSource();
+ String schema = dbUnitExecution.schema();
+ if (StringUtils.isEmpty(schema))
+ {
+ schema = null;
+ }
+
+ IDatabaseConnection connection = new DatabaseConnection(
+ getDatasource(dataSourceName).getConnection(),
+ schema);
+
+ try
+ {
+ ITableFilter tableFilter = new RegExpTableFilter(dbUnitExecution.excludedTables());
+
+ if (dbUnitExecution.truncateAll())
+ {
+ truncateAll(connection, tableFilter, dataSourceName, dbUnitExecution
+ .truncateOperation()
+ .newInstance());
+ }
+
+ DatabaseOperation dbOperation = dbUnitExecution.insertOperation().newInstance();
+ for (String datasetFile : datasets)
+ {
+ importDataSet(createDataset(datasetFile), connection, tableFilter, dataSourceName, dbOperation);
+ }
+ }
+ finally
+ {
+ connection.close();
+ }
+ }
+ }
+
+ /**
+ * @param datasetFile
+ * @return
+ * @throws IOException
+ * @throws DataSetException
+ */
+ private IDataSet createDataset(String datasetFile) throws IOException, DataSetException
+ {
+ IDataSet dataSet = datasetCache.get(datasetFile);
+ if (dataSet == null)
+ {
+ URL datasetUrl = getClass().getResource(datasetFile);
+ if (datasetUrl == null)
+ {
+ throw new IllegalArgumentException("Dataset " + datasetFile + " not found");
+ }
+ dataSet = DbUnitUtils.loadDataset(datasetUrl);
+ datasetCache.put(datasetFile, dataSet);
+ }
+ return dataSet;
+ }
+
+ private void importDataSet(IDataSet dataSet, IDatabaseConnection connection, ITableFilter tableFilter,
+ String dataSourceName, DatabaseOperation databaseOperation) throws SQLException, DataSetException,
+ DatabaseUnitException
+ {
+
+ if (dataSet == null)
+ {
+ throw new IllegalArgumentException("dataSet is null");
+ }
+
+ IDataSet orderedDataset = new FilteredDataSet(tableFilter, dataSet);
+ if (log.isDebugEnabled())
+ {
+ log.debug("Tables: {}", ArrayUtils.toString(orderedDataset.getTableNames()));
+ }
+
+ // if a sorted dataset is available, use table sequence for sorting
+ IDataSet truncateDataSet = getTruncateDataset(dataSourceName, connection.getSchema());
+ if (truncateDataSet != null)
+ {
+ ITableFilter filter = new SequenceTableFilter(truncateDataSet.getTableNames());
+ orderedDataset = new FilteredDataSet(filter, dataSet);
+ }
+
+ if (dataSet != null)
+ {
+ databaseOperation.execute(connection, orderedDataset);
+ }
+
+ }
+
+ /**
+ * @param connection
+ * @param tableFilter
+ * @throws SQLException
+ * @throws DataSetException
+ * @throws DatabaseUnitException
+ */
+ private void truncateAll(IDatabaseConnection connection, ITableFilter tableFilter, String dataSourceName,
+ DatabaseOperation databaseOperation) throws SQLException, DataSetException, DatabaseUnitException
+ {
+ IDataSet truncateDataSet = getTruncateDataset(dataSourceName, connection.getSchema());
+ if (truncateDataSet == null)
+ {
+ log.debug("Generating sorted dataset for initial cleanup");
+ IDataSet unsortedDataSet = connection.createDataSet();
+
+ 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));
+ storeTruncateDataset(dataSourceName, connection.getSchema(), truncateDataSet);
+ log.debug("Sorted dataset generated");
+ }
+
+ log.debug("Tables truncateDataSet: {}", ArrayUtils.toString(truncateDataSet.getTableNames()));
+ if (truncateDataSet != null)
+ {
+ databaseOperation.execute(connection, truncateDataSet);
+ }
+ }
+
+ private IDataSet getTruncateDataset(String datasourceName, String schema)
+ {
+ return truncateDataSetCache.get(datasourceName + "_" + StringUtils.defaultString(schema));
+ }
+
+ private IDataSet storeTruncateDataset(String datasourceName, String schema, IDataSet dataset)
+ {
+ return truncateDataSetCache.put(datasourceName + "_" + StringUtils.defaultString(schema), dataset);
+ }
+
+ @SuppressWarnings("unchecked")
+ protected DataSource getDatasource(String name)
+ {
+ if (StringUtils.isEmpty(name))
+ {
+ Map<String, DataSource> dsMap = applicationContext.getBeansOfType(DataSource.class);
+ if (dsMap == null || dsMap.size() != 1)
+ {
+ throw new RuntimeException(
+ "Unable to find a datasource in spring applicationContext, please specify the datasource bean name "
+ + "using the \"datasource\" attribute of @DbUnitConfiguration");
+ }
+ return dsMap.values().iterator().next();
+ }
+ return (DataSource) applicationContext.getBean(name);
+ }
+}
Property changes on: trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitTestContext.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
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-09 23:06:51 UTC (rev 524)
+++ trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitUtils.java 2008-01-12 10:46:12 UTC (rev 525)
@@ -1,3 +1,18 @@
+/*
+ * 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;
import java.io.File;
Modified: trunk/openutils-testing/src/main/java/it/openutils/testing/RegExpTableFilter.java
===================================================================
--- trunk/openutils-testing/src/main/java/it/openutils/testing/RegExpTableFilter.java 2008-01-09 23:06:51 UTC (rev 524)
+++ trunk/openutils-testing/src/main/java/it/openutils/testing/RegExpTableFilter.java 2008-01-12 10:46:12 UTC (rev 525)
@@ -1,3 +1,18 @@
+/*
+ * 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;
import java.util.regex.Pattern;
Modified: trunk/openutils-testing-junit/pom.xml
===================================================================
--- trunk/openutils-testing-junit/pom.xml 2008-01-09 23:06:51 UTC (rev 524)
+++ trunk/openutils-testing-junit/pom.xml 2008-01-12 10:46:12 UTC (rev 525)
@@ -97,7 +97,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>3.8.1</version>
+ <version>4.4</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
Added: trunk/openutils-testing-junit/src/main/java/it/openutils/testing/junit/AbstractDbUnitJunitSpringContextTests.java
===================================================================
--- trunk/openutils-testing-junit/src/main/java/it/openutils/testing/junit/AbstractDbUnitJunitSpringContextTests.java (rev 0)
+++ trunk/openutils-testing-junit/src/main/java/it/openutils/testing/junit/AbstractDbUnitJunitSpringContextTests.java 2008-01-12 10:46:12 UTC (rev 525)
@@ -0,0 +1,54 @@
+/*
+ * 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.junit;
+
+import it.openutils.testing.DbUnitTestContext;
+
+import org.junit.Before;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
+
+
+/**
+ * @author fgiust
+ * @version $Id: $
+ */
+public class AbstractDbUnitJunitSpringContextTests extends AbstractJUnit4SpringContextTests
+{
+
+ /**
+ * Slf4j logger that can be reused in subclasses.
+ */
+ protected Logger log = LoggerFactory.getLogger(getClass());
+
+ /**
+ * DBUnit text context.
+ */
+ private DbUnitTestContext dbUnitTestContext;
+
+ /**
+ * Setup the Database before running the test method.
+ * @throws Exception Any exception.
+ */
+ @SuppressWarnings("unchecked")
+ @Before
+ protected void setUpDbUnit() throws Exception
+ {
+ dbUnitTestContext = new DbUnitTestContext(this, applicationContext);
+ dbUnitTestContext.setUpDbUnit();
+ }
+}
Property changes on: trunk/openutils-testing-junit/src/main/java/it/openutils/testing/junit/AbstractDbUnitJunitSpringContextTests.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified: trunk/openutils-testing-junit/src/main/java/it/openutils/testing/junit/DbUnitTestCase.java
===================================================================
--- trunk/openutils-testing-junit/src/main/java/it/openutils/testing/junit/DbUnitTestCase.java 2008-01-09 23:06:51 UTC (rev 524)
+++ trunk/openutils-testing-junit/src/main/java/it/openutils/testing/junit/DbUnitTestCase.java 2008-01-12 10:46:12 UTC (rev 525)
@@ -1,5 +1,5 @@
/*
- * Copyright 2005 Fabrizio Giustina.
+ * 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.
@@ -45,7 +45,9 @@
* Base class for running DAO tests.
* @author fgiust
* @version $Revision $ ($Author $)
+ * @deprecated use {@link AbstractDbUnitJunitSpringContextTests}
*/
+@Deprecated
public abstract class DbUnitTestCase extends SpringTestCase
{
Modified: trunk/openutils-testing-junit/src/main/java/it/openutils/testing/junit/GenericsDbUnitTestCase.java
===================================================================
--- trunk/openutils-testing-junit/src/main/java/it/openutils/testing/junit/GenericsDbUnitTestCase.java 2008-01-09 23:06:51 UTC (rev 524)
+++ trunk/openutils-testing-junit/src/main/java/it/openutils/testing/junit/GenericsDbUnitTestCase.java 2008-01-12 10:46:12 UTC (rev 525)
@@ -1,5 +1,5 @@
/*
- * Copyright 2005 Fabrizio Giustina.
+ * 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.
@@ -28,7 +28,9 @@
* from Spring is made available through the <code>instance</code> protected field.
* @author fgiust
* @version $Id$
+ * @deprecated use {@link AbstractDbUnitJunitSpringContextTests}
*/
+@Deprecated
public class GenericsDbUnitTestCase<D> extends DbUnitTestCase
{
Modified: trunk/openutils-testing-junit/src/main/java/it/openutils/testing/junit/SpringTestCase.java
===================================================================
--- trunk/openutils-testing-junit/src/main/java/it/openutils/testing/junit/SpringTestCase.java 2008-01-09 23:06:51 UTC (rev 524)
+++ trunk/openutils-testing-junit/src/main/java/it/openutils/testing/junit/SpringTestCase.java 2008-01-12 10:46:12 UTC (rev 525)
@@ -1,5 +1,5 @@
/*
- * Copyright 2005 Fabrizio Giustina.
+ * 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.
@@ -27,7 +27,9 @@
* Base class for running spring-based tests.
* @author fgiust
* @version $Revision $ ($Author $)
+ * @deprecated {@link org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests}
*/
+@Deprecated
public abstract class SpringTestCase extends TestCase
{
@@ -56,7 +58,7 @@
if (ctx == null)
{
// load Spring's BeanFactory
- String[] paths = {DEFAULT_TEST_CONTEXT_FILE};
+ String[] paths = {DEFAULT_TEST_CONTEXT_FILE };
ctx = new ClassPathXmlApplicationContext(paths);
}
Modified: trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/AbstractDbUnitTestNGSpringContextTests.java
===================================================================
--- trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/AbstractDbUnitTestNGSpringContextTests.java 2008-01-09 23:06:51 UTC (rev 524)
+++ trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/AbstractDbUnitTestNGSpringContextTests.java 2008-01-12 10:46:12 UTC (rev 525)
@@ -1,30 +1,22 @@
+/*
+ * 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.testng;
-import it.openutils.testing.DbUnitConfiguration;
-import it.openutils.testing.DbUnitExecution;
-import it.openutils.testing.DbUnitUtils;
-import it.openutils.testing.RegExpTableFilter;
+import it.openutils.testing.DbUnitTestContext;
-import java.io.IOException;
-import java.net.URL;
-import java.sql.SQLException;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.sql.DataSource;
-
-import org.apache.commons.lang.ArrayUtils;
-import org.apache.commons.lang.StringUtils;
-import org.dbunit.DatabaseUnitException;
-import org.dbunit.database.DatabaseConnection;
-import org.dbunit.database.DatabaseSequenceFilter;
-import org.dbunit.database.IDatabaseConnection;
-import org.dbunit.dataset.DataSetException;
-import org.dbunit.dataset.FilteredDataSet;
-import org.dbunit.dataset.IDataSet;
-import org.dbunit.dataset.filter.ITableFilter;
-import org.dbunit.dataset.filter.SequenceTableFilter;
-import org.dbunit.operation.DatabaseOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
@@ -39,22 +31,16 @@
{
/**
- * Logger.
+ * Slf4j logger that can be reused in subclasses.
*/
- private Logger log = LoggerFactory.getLogger(getClass());
+ protected Logger log = LoggerFactory.getLogger(getClass());
/**
- * Dataset cache.
+ * DBUnit text context.
*/
- private Map<String, IDataSet> datasetCache = new HashMap<String, IDataSet>();
+ private DbUnitTestContext dbUnitTestContext;
/**
- * Truncate dataset cache. This is kept as a static attribute since the creation of the dataset is very expensive
- * and it doesn't change across tests.
- */
- protected static Map<String, IDataSet> truncateDataSetCache = new HashMap<String, IDataSet>();
-
- /**
* Setup the Database before running the test method.
* @throws Exception Any exception.
*/
@@ -62,161 +48,8 @@
@BeforeMethod
protected void setUpDbUnit() throws Exception
{
- DbUnitExecution singleDbUnitExecution = getClass().getAnnotation(DbUnitExecution.class);
-
- DbUnitExecution[] executions;
- if (singleDbUnitExecution != null)
- {
- executions = new DbUnitExecution[]{singleDbUnitExecution };
- }
- else
- {
- DbUnitConfiguration dbUnitConfiguration = getClass().getAnnotation(DbUnitConfiguration.class);
- executions = dbUnitConfiguration.dbUnitExecutions();
- }
-
- for (DbUnitExecution dbUnitExecution : executions)
- {
- String[] datasets = dbUnitExecution.datasets();
- String dataSourceName = dbUnitExecution.dataSource();
- String schema = dbUnitExecution.schema();
- if (StringUtils.isEmpty(schema))
- {
- schema = null;
- }
-
- IDatabaseConnection connection = new DatabaseConnection(
- getDatasource(dataSourceName).getConnection(),
- schema);
-
- try
- {
- ITableFilter tableFilter = new RegExpTableFilter(dbUnitExecution.excludedTables());
-
- if (dbUnitExecution.truncateAll())
- {
- truncateAll(connection, tableFilter, dataSourceName);
- }
-
- for (String datasetFile : datasets)
- {
- importDataSet(createDataset(datasetFile), connection, tableFilter, dataSourceName);
- }
- }
- finally
- {
- connection.close();
- }
- }
+ dbUnitTestContext = new DbUnitTestContext(this, applicationContext);
+ dbUnitTestContext.setUpDbUnit();
}
- /**
- * @param datasetFile
- * @return
- * @throws IOException
- * @throws DataSetException
- */
- private IDataSet createDataset(String datasetFile) throws IOException, DataSetException
- {
- IDataSet dataSet = datasetCache.get(datasetFile);
- if (dataSet == null)
- {
- URL datasetUrl = getClass().getResource(datasetFile);
- if (datasetUrl == null)
- {
- throw new IllegalArgumentException("Dataset " + datasetFile + " not found");
- }
- dataSet = DbUnitUtils.loadDataset(datasetUrl);
- datasetCache.put(datasetFile, dataSet);
- }
- return dataSet;
- }
-
- private void importDataSet(IDataSet dataSet, IDatabaseConnection connection, ITableFilter tableFilter,
- String dataSourceName) throws SQLException, DataSetException, DatabaseUnitException
- {
-
- if (dataSet == null)
- {
- throw new IllegalArgumentException("dataSet is null");
- }
- IDataSet orderedDataset = new FilteredDataSet(tableFilter, dataSet);
-
- log.debug("Tables: {}", ArrayUtils.toString(orderedDataset.getTableNames()));
-
- // if a sorted dataset is available, use table sequence for sorting
- IDataSet truncateDataSet = getTruncateDataset(dataSourceName, connection.getSchema());
- if (truncateDataSet != null)
- {
- ITableFilter filter = new SequenceTableFilter(truncateDataSet.getTableNames());
- orderedDataset = new FilteredDataSet(filter, dataSet);
- }
-
- if (dataSet != null)
- {
- DatabaseOperation.INSERT.execute(connection, orderedDataset);
- }
-
- }
-
- /**
- * @param connection
- * @param tableFilter
- * @throws SQLException
- * @throws DataSetException
- * @throws DatabaseUnitException
- */
- private void truncateAll(IDatabaseConnection connection, ITableFilter tableFilter, String dataSourceName)
- throws SQLException, DataSetException, DatabaseUnitException
- {
- IDataSet truncateDataSet = getTruncateDataset(dataSourceName, connection.getSchema());
- if (truncateDataSet == null)
- {
- log.debug("Generating sorted dataset for initial cleanup");
- IDataSet unsortedDataSet = connection.createDataSet();
-
- 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));
- storeTruncateDataset(dataSourceName, connection.getSchema(), truncateDataSet);
- log.debug("Sorted dataset generated");
- }
-
- log.debug("Tables truncateDataSet: {}", ArrayUtils.toString(truncateDataSet.getTableNames()));
- if (truncateDataSet != null)
- {
- DatabaseOperation.DELETE_ALL.execute(connection, truncateDataSet);
- }
- }
-
- private IDataSet getTruncateDataset(String datasourceName, String schema)
- {
- return truncateDataSetCache.get(datasourceName + "_" + StringUtils.defaultString(schema));
- }
-
- private IDataSet storeTruncateDataset(String datasourceName, String schema, IDataSet dataset)
- {
- return truncateDataSetCache.put(datasourceName + "_" + StringUtils.defaultString(schema), dataset);
- }
-
- @SuppressWarnings("unchecked")
- protected DataSource getDatasource(String name)
- {
- if (StringUtils.isEmpty(name))
- {
- Map<String, DataSource> dsMap = applicationContext.getBeansOfType(DataSource.class);
- if (dsMap == null || dsMap.size() != 1)
- {
- throw new RuntimeException(
- "Unable to find a datasource in spring applicationContext, please specify the datasource bean name "
- + "using the \"datasource\" attribute of @DbUnitConfiguration");
- }
- return dsMap.values().iterator().next();
- }
- return (DataSource) applicationContext.getBean(name);
- }
-
}
Modified: trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/DbUnitTestCase.java
===================================================================
--- trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/DbUnitTestCase.java 2008-01-09 23:06:51 UTC (rev 524)
+++ trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/DbUnitTestCase.java 2008-01-12 10:46:12 UTC (rev 525)
@@ -1,5 +1,5 @@
/*
- * Copyright 2005 Fabrizio Giustina.
+ * 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.
Modified: trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/GenericsDbUnitTestCase.java
===================================================================
--- trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/GenericsDbUnitTestCase.java 2008-01-09 23:06:51 UTC (rev 524)
+++ trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/GenericsDbUnitTestCase.java 2008-01-12 10:46:12 UTC (rev 525)
@@ -1,5 +1,5 @@
/*
- * Copyright 2005 Fabrizio Giustina.
+ * 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.
Modified: trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/SpringTestCase.java
===================================================================
--- trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/SpringTestCase.java 2008-01-09 23:06:51 UTC (rev 524)
+++ trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/SpringTestCase.java 2008-01-12 10:46:12 UTC (rev 525)
@@ -1,5 +1,5 @@
/*
- * Copyright 2005 Fabrizio Giustina.
+ * 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.
Modified: trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/utils/DateAssert.java
===================================================================
--- trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/utils/DateAssert.java 2008-01-09 23:06:51 UTC (rev 524)
+++ trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/utils/DateAssert.java 2008-01-12 10:46:12 UTC (rev 525)
@@ -1,5 +1,17 @@
/*
- * Copyright (c) Openmind. All rights reserved. http://www.openmindonline.it
+ * 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.testng.utils;
Modified: trunk/openutils-testing-testng/src/test/java/it/openutils/testing/testng/MultipleDatasourceDbUnitTest.java
===================================================================
--- trunk/openutils-testing-testng/src/test/java/it/openutils/testing/testng/MultipleDatasourceDbUnitTest.java 2008-01-09 23:06:51 UTC (rev 524)
+++ trunk/openutils-testing-testng/src/test/java/it/openutils/testing/testng/MultipleDatasourceDbUnitTest.java 2008-01-12 10:46:12 UTC (rev 525)
@@ -1,3 +1,18 @@
+/*
+ * 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.testng;
import it.openutils.testing.DbUnitConfiguration;
Modified: trunk/openutils-testing-testng/src/test/java/it/openutils/testing/testng/SingleDatasourceDbUnitTest.java
===================================================================
--- trunk/openutils-testing-testng/src/test/java/it/openutils/testing/testng/SingleDatasourceDbUnitTest.java 2008-01-09 23:06:51 UTC (rev 524)
+++ trunk/openutils-testing-testng/src/test/java/it/openutils/testing/testng/SingleDatasourceDbUnitTest.java 2008-01-12 10:46:12 UTC (rev 525)
@@ -1,3 +1,18 @@
+/*
+ * 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.testng;
import it.openutils.testing.DbUnitExecution;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fg...@us...> - 2008-01-20 20:47:22
|
Revision: 541
http://openutils.svn.sourceforge.net/openutils/?rev=541&view=rev
Author: fgiust
Date: 2008-01-20 12:47:20 -0800 (Sun, 20 Jan 2008)
Log Message:
-----------
standard dbunit operations can now be used
Modified Paths:
--------------
trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitTestContext.java
trunk/openutils-testing/src/site/apt/index.apt
trunk/openutils-testing-testng/derby.log
trunk/openutils-testing-testng/src/test/java/it/openutils/testing/testng/SingleDatasourceDbUnitTest.java
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-20 19:29:56 UTC (rev 540)
+++ trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitTestContext.java 2008-01-20 20:47:20 UTC (rev 541)
@@ -35,6 +35,12 @@
import org.dbunit.dataset.filter.ITableFilter;
import org.dbunit.dataset.filter.SequenceTableFilter;
import org.dbunit.operation.DatabaseOperation;
+import org.dbunit.operation.DeleteAllOperation;
+import org.dbunit.operation.DeleteOperation;
+import org.dbunit.operation.InsertOperation;
+import org.dbunit.operation.RefreshOperation;
+import org.dbunit.operation.TruncateTableOperation;
+import org.dbunit.operation.UpdateOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
@@ -48,12 +54,24 @@
{
/**
+ * Truncate dataset cache. This is kept as a static attribute since the creation of the dataset is very expensive
+ * and it doesn't change across tests.
+ */
+ protected static Map<String, IDataSet> truncateDataSetCache = new HashMap<String, IDataSet>();
+
+ /**
* Logger.
*/
private static Logger log = LoggerFactory.getLogger(DbUnitTestContext.class);
+ /**
+ * The test instance.
+ */
private Object testcase;
+ /**
+ * Spring application context.
+ */
private ApplicationContext applicationContext;
/**
@@ -62,11 +80,10 @@
private Map<String, IDataSet> datasetCache = new HashMap<String, IDataSet>();
/**
- * Truncate dataset cache. This is kept as a static attribute since the creation of the dataset is very expensive
- * and it doesn't change across tests.
+ * Instantiates a new DbUnitTestContext
+ * @param testcase test instance
+ * @param applicationContext Spring application context
*/
- protected static Map<String, IDataSet> truncateDataSetCache = new HashMap<String, IDataSet>();
-
public DbUnitTestContext(Object testcase, ApplicationContext applicationContext)
{
this.testcase = testcase;
@@ -113,12 +130,11 @@
if (dbUnitExecution.truncateAll())
{
- truncateAll(connection, tableFilter, dataSourceName, dbUnitExecution
- .truncateOperation()
- .newInstance());
+ truncateAll(connection, tableFilter, dataSourceName, getDatabaseOperation(dbUnitExecution
+ .truncateOperation()));
}
- DatabaseOperation dbOperation = dbUnitExecution.insertOperation().newInstance();
+ DatabaseOperation dbOperation = getDatabaseOperation(dbUnitExecution.insertOperation());
for (String datasetFile : datasets)
{
importDataSet(createDataset(datasetFile), connection, tableFilter, dataSourceName, dbOperation);
@@ -132,8 +148,54 @@
}
/**
- * @param datasetFile
- * @return
+ * Instantiates the givec Database Operation. Standard operations in the <code>org.dbunit.operation</code> package
+ * have protected constructors and needs to be accessed using the public static fields in
+ * <code>org.dbunit.operation.DatabaseOperation</code>.
+ * @param dboperationClass db operation class
+ * @return db operation instance
+ * @throws InstantiationException if the given db operation class cannot be instantiated
+ * @throws IllegalAccessException if the given db operation class cannot be instantiated
+ */
+ private DatabaseOperation getDatabaseOperation(Class< ? extends DatabaseOperation> dboperationClass)
+ throws InstantiationException, IllegalAccessException
+ {
+ if (UpdateOperation.class.equals(dboperationClass))
+ {
+ return DatabaseOperation.UPDATE;
+ }
+ else if (InsertOperation.class.equals(dboperationClass))
+ {
+ return DatabaseOperation.INSERT;
+ }
+ else if (RefreshOperation.class.equals(dboperationClass))
+ {
+ return DatabaseOperation.REFRESH;
+ }
+ else if (DeleteOperation.class.equals(dboperationClass))
+ {
+ return DatabaseOperation.DELETE;
+ }
+ else if (DeleteAllOperation.class.equals(dboperationClass))
+ {
+ return DatabaseOperation.DELETE_ALL;
+ }
+ else if (TruncateTableOperation.class.equals(dboperationClass))
+ {
+ return DatabaseOperation.TRUNCATE_TABLE;
+ }
+ else if (DeleteOperation.class.equals(dboperationClass))
+ {
+ return DatabaseOperation.UPDATE;
+ }
+
+ return dboperationClass.newInstance();
+
+ }
+
+ /**
+ * Creates a dataset instance by fetching a file from the classpath
+ * @param datasetFile name of the file, will be loaded from the classpath
+ * @return IDataSet instance
* @throws IOException
* @throws DataSetException
*/
@@ -227,6 +289,11 @@
return truncateDataSetCache.put(datasourceName + "_" + StringUtils.defaultString(schema), dataset);
}
+ /**
+ * Loads a named datasource from the spring context.
+ * @param name datasource name.
+ * @return Datasource instance
+ */
@SuppressWarnings("unchecked")
protected DataSource getDatasource(String name)
{
Modified: trunk/openutils-testing/src/site/apt/index.apt
===================================================================
--- trunk/openutils-testing/src/site/apt/index.apt 2008-01-20 19:29:56 UTC (rev 540)
+++ trunk/openutils-testing/src/site/apt/index.apt 2008-01-20 20:47:20 UTC (rev 541)
@@ -6,3 +6,10 @@
openutils-testing
+
+
+
+Released versions
+
+ Check it at {{{http://www.mvnrepository.com/artifact/net.sourceforge.openutils/openutils-testing}http://www.mvnrepository.com/artifact/net.sourceforge.openutils/openutils-testing}}
+
Modified: trunk/openutils-testing-testng/derby.log
===================================================================
--- trunk/openutils-testing-testng/derby.log 2008-01-20 19:29:56 UTC (rev 540)
+++ trunk/openutils-testing-testng/derby.log 2008-01-20 20:47:20 UTC (rev 541)
@@ -1,12 +1,6 @@
----------------------------------------------------------------
-2008-01-09 22:30:08.630 GMT:
- Booting Derby version The Apache Software Foundation - Apache Derby - 10.2.2.0 - (485682): instance c013800d-0117-60ac-bb18-00000229e5c0
+2008-01-20 20:42:12.281 GMT:
+ Booting Derby version The Apache Software Foundation - Apache Derby - 10.2.2.0 - (485682): instance c013800d-0117-98ef-dce7-000001d801b8
on database directory /data/apps/openmind/openutils-trunk/openutils-testing-testng/target/test-db1
Database Class Loader started - derby.database.classpath=''
-----------------------------------------------------------------
-2008-01-09 22:30:09.498 GMT:
- Booting Derby version The Apache Software Foundation - Apache Derby - 10.2.2.0 - (485682): instance f81e0010-0117-60ac-bb18-00000229e5c0
-on database directory /data/apps/openmind/openutils-trunk/openutils-testing-testng/target/test-db2
-
-Database Class Loader started - derby.database.classpath=''
Modified: trunk/openutils-testing-testng/src/test/java/it/openutils/testing/testng/SingleDatasourceDbUnitTest.java
===================================================================
--- trunk/openutils-testing-testng/src/test/java/it/openutils/testing/testng/SingleDatasourceDbUnitTest.java 2008-01-20 19:29:56 UTC (rev 540)
+++ trunk/openutils-testing-testng/src/test/java/it/openutils/testing/testng/SingleDatasourceDbUnitTest.java 2008-01-20 20:47:20 UTC (rev 541)
@@ -17,6 +17,7 @@
import it.openutils.testing.DbUnitExecution;
+import org.dbunit.operation.InsertOperation;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestExecutionListeners;
import org.springframework.test.context.transaction.TransactionConfiguration;
@@ -30,7 +31,7 @@
* @version $Id: $
*/
@ContextConfiguration(locations = {"/spring-tests.xml" })
-@DbUnitExecution(datasets = {"/db1-load.xml" }, dataSource = "dataSource1")
+@DbUnitExecution(datasets = {"/db1-load.xml" }, dataSource = "dataSource1", insertOperation = InsertOperation.class)
@TestExecutionListeners({TransactionalTestExecutionListener.class })
@Transactional
@TransactionConfiguration(transactionManager = "transactionManager1")
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fg...@us...> - 2008-01-22 21:17:51
|
Revision: 543
http://openutils.svn.sourceforge.net/openutils/?rev=543&view=rev
Author: fgiust
Date: 2008-01-22 13:17:56 -0800 (Tue, 22 Jan 2008)
Log Message:
-----------
minor changes
Modified Paths:
--------------
trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitTestContext.java
trunk/openutils-testing-junit/src/main/java/it/openutils/testing/junit/AbstractDbUnitJunitSpringContextTests.java
trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/AbstractDbUnitTestNGSpringContextTests.java
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-21 09:07:23 UTC (rev 542)
+++ trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitTestContext.java 2008-01-22 21:17:56 UTC (rev 543)
@@ -15,7 +15,11 @@
*/
package it.openutils.testing;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.OutputStream;
import java.net.URL;
import java.sql.SQLException;
import java.util.HashMap;
@@ -32,8 +36,10 @@
import org.dbunit.dataset.DataSetException;
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.filter.SequenceTableFilter;
+import org.dbunit.dataset.xml.XmlDataSet;
import org.dbunit.operation.DatabaseOperation;
import org.dbunit.operation.DeleteAllOperation;
import org.dbunit.operation.DeleteOperation;
@@ -99,7 +105,7 @@
{
DbUnitExecution singleDbUnitExecution = testcase.getClass().getAnnotation(DbUnitExecution.class);
- DbUnitExecution[] executions;
+ DbUnitExecution[] executions = null;
if (singleDbUnitExecution != null)
{
executions = new DbUnitExecution[]{singleDbUnitExecution };
@@ -107,43 +113,48 @@
else
{
DbUnitConfiguration dbUnitConfiguration = testcase.getClass().getAnnotation(DbUnitConfiguration.class);
- executions = dbUnitConfiguration.dbUnitExecutions();
+ if (dbUnitConfiguration != null)
+ {
+ executions = dbUnitConfiguration.dbUnitExecutions();
+ }
}
-
- for (DbUnitExecution dbUnitExecution : executions)
+ if (executions != null)
{
- String[] datasets = dbUnitExecution.datasets();
- String dataSourceName = dbUnitExecution.dataSource();
- String schema = dbUnitExecution.schema();
- if (StringUtils.isEmpty(schema))
+ for (DbUnitExecution dbUnitExecution : executions)
{
- schema = null;
- }
+ String[] datasets = dbUnitExecution.datasets();
+ String dataSourceName = dbUnitExecution.dataSource();
+ String schema = dbUnitExecution.schema();
+ if (StringUtils.isEmpty(schema))
+ {
+ schema = null;
+ }
- IDatabaseConnection connection = new DatabaseConnection(
- getDatasource(dataSourceName).getConnection(),
- schema);
+ IDatabaseConnection connection = new DatabaseConnection(
+ getDatasource(dataSourceName).getConnection(),
+ schema);
- try
- {
- ITableFilter tableFilter = new RegExpTableFilter(dbUnitExecution.excludedTables());
+ try
+ {
+ ITableFilter tableFilter = new RegExpTableFilter(dbUnitExecution.excludedTables());
- if (dbUnitExecution.truncateAll())
- {
- truncateAll(connection, tableFilter, dataSourceName, getDatabaseOperation(dbUnitExecution
- .truncateOperation()));
+ if (dbUnitExecution.truncateAll())
+ {
+ truncateAll(connection, tableFilter, dataSourceName, getDatabaseOperation(dbUnitExecution
+ .truncateOperation()));
+ }
+
+ DatabaseOperation dbOperation = getDatabaseOperation(dbUnitExecution.insertOperation());
+ for (String datasetFile : datasets)
+ {
+ importDataSet(createDataset(datasetFile), connection, tableFilter, dataSourceName, dbOperation);
+ }
}
-
- DatabaseOperation dbOperation = getDatabaseOperation(dbUnitExecution.insertOperation());
- for (String datasetFile : datasets)
+ finally
{
- importDataSet(createDataset(datasetFile), connection, tableFilter, dataSourceName, dbOperation);
+ connection.close();
}
}
- finally
- {
- connection.close();
- }
}
}
@@ -310,4 +321,40 @@
}
return (DataSource) applicationContext.getBean(name);
}
+
+ /**
+ * Exports a list of table to an xml/xsl file
+ * @param file The file name we save the dataset to
+ * @param dataSource datasource to use
+ * @param schema optional schema name
+ * @param tableNames optional list of table names
+ * @throws IOException An IO Exception.
+ * @throws DataSetException A dataset exception.
+ * @throws SQLException A SQL Exception.
+ */
+ public void exportDataset(File file, DataSource dataSource, String schema, String[] tableNames) throws IOException,
+ DataSetException, SQLException
+ {
+ IDatabaseConnection connection = new DatabaseConnection(dataSource.getConnection(), schema);
+
+ IDataSet fullDataSet = connection.createDataSet();
+
+ if (tableNames != null && tableNames.length > 0)
+ {
+ fullDataSet = new FilteredDataSet(tableNames, fullDataSet);
+ }
+
+ OutputStream fos = new BufferedOutputStream(new FileOutputStream(file));
+ if (file.getName().toLowerCase().endsWith(".xls"))
+ {
+ XlsDataSet.write(fullDataSet, fos);
+ }
+ else
+ {
+ XmlDataSet.write(fullDataSet, fos);
+ }
+ fos.close();
+
+ log.info("Dataset exported at {}", file.getAbsolutePath());
+ }
}
Modified: trunk/openutils-testing-junit/src/main/java/it/openutils/testing/junit/AbstractDbUnitJunitSpringContextTests.java
===================================================================
--- trunk/openutils-testing-junit/src/main/java/it/openutils/testing/junit/AbstractDbUnitJunitSpringContextTests.java 2008-01-21 09:07:23 UTC (rev 542)
+++ trunk/openutils-testing-junit/src/main/java/it/openutils/testing/junit/AbstractDbUnitJunitSpringContextTests.java 2008-01-22 21:17:56 UTC (rev 543)
@@ -38,7 +38,7 @@
/**
* DBUnit text context.
*/
- private DbUnitTestContext dbUnitTestContext;
+ protected DbUnitTestContext dbUnitTestContext;
/**
* Setup the Database before running the test method.
Modified: trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/AbstractDbUnitTestNGSpringContextTests.java
===================================================================
--- trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/AbstractDbUnitTestNGSpringContextTests.java 2008-01-21 09:07:23 UTC (rev 542)
+++ trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/AbstractDbUnitTestNGSpringContextTests.java 2008-01-22 21:17:56 UTC (rev 543)
@@ -38,7 +38,7 @@
/**
* DBUnit text context.
*/
- private DbUnitTestContext dbUnitTestContext;
+ protected DbUnitTestContext dbUnitTestContext;
/**
* Setup the Database before running the test method.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fg...@us...> - 2008-01-26 19:07:41
|
Revision: 550
http://openutils.svn.sourceforge.net/openutils/?rev=550&view=rev
Author: fgiust
Date: 2008-01-26 11:07:44 -0800 (Sat, 26 Jan 2008)
Log Message:
-----------
docs!
Modified Paths:
--------------
trunk/openutils-testing/src/site/apt/index.apt
Added Paths:
-----------
trunk/openutils-testing/src/site/apt/dbunit.apt
trunk/openutils-testing-junit/src/site/apt/
trunk/openutils-testing-junit/src/site/apt/index.apt
trunk/openutils-testing-testng/src/site/apt/
trunk/openutils-testing-testng/src/site/apt/index.apt
Added: trunk/openutils-testing/src/site/apt/dbunit.apt
===================================================================
--- trunk/openutils-testing/src/site/apt/dbunit.apt (rev 0)
+++ trunk/openutils-testing/src/site/apt/dbunit.apt 2008-01-26 19:07:44 UTC (rev 550)
@@ -0,0 +1,76 @@
+ --------------------------
+ O p e n u t i l s
+ --------------------------
+ Fabrizio Giustina
+ --------------------------
+
+
+DbUnit tests
+
+ Openutils provide a base class that take cares of the common operations involved in preparing the test environment using
+ DbUnit.
+
+ You can extend <<<it.openutils.testing.testng.AbstractDbUnitTestNGSpringContextTests>>> or
+ <<<it.openutils.testing.junit.AbstractDbUnitJunitSpringContextTests>>>, depending on the test framework of your choice
+ (remember to include the appropriate dependency, openutils-testing-testng or openutils-testing-junit).
+ Apart from the underline test framework used, there is no difference in how those class will work.
+
+ Those base classes extend the standard <<<Abstract*SpringContextTests>>> classes provided by Spring, so they support
+ dependency injection and needs to be configured from a Spring context.
+
+How to
+
+ All the setup can be configured using annotations. This is a sample test that can make use of data loaded by DbUnit:
+
++----------------------------------------------+
+
+@ContextConfiguration(locations = {"/spring-tests.xml" })
+@DbUnitExecution(datasets = {"/db1-load.xml" })
+public class SampleDbUnitTest extends AbstractDbUnitTestNGSpringContextTests
+{
+ @Test
+ public void testSomething() {
+ ...
+ }
+}
+
++----------------------------------------------+
+
+ The <<<DbUnitExecution>>> annotation controls how the setup will be performed. It can be configured with a list of file names
+ (xml od xsl DbUnit datasets) that will be loaded before every single method in this test class is executed.
+
+ In detail the setup that will be performed before each method is:
+
+ * truncate *any table* in the database. This can be turned of by the <<<truncateAll>>> DbUnitExecution parameter
+
+ * load the given datasets into the db
+
+ []
+
+ You can setup also more than one execution if your tests depend on more than one database or schema, annotating your
+ class like in this example:
+
++----------------------------------------------+
+
+@DbUnitConfiguration(dbUnitExecutions = {
+ @DbUnitExecution(datasets = {"/db1-load.xml" }, dataSource = "dataSource1"),
+ @DbUnitExecution(datasets = {"/db2-load.xml" }, dataSource = "dataSource2") })
+
++----------------------------------------------+
+
+
+ Note that this test classes don't extend Spring transactional tests, so you need to manually turn on Transactions using
+ standard Spring annotations:
+
++----------------------------------------------+
+
+@TestExecutionListeners({TransactionalTestExecutionListener.class })
+@Transactional
+
++----------------------------------------------+
+
+ Also note that the content of your db will definitively be modified by these tests, they are expected to be run on a
+ test-only instance!
+
+
+
Property changes on: trunk/openutils-testing/src/site/apt/dbunit.apt
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified: trunk/openutils-testing/src/site/apt/index.apt
===================================================================
--- trunk/openutils-testing/src/site/apt/index.apt 2008-01-26 18:39:46 UTC (rev 549)
+++ trunk/openutils-testing/src/site/apt/index.apt 2008-01-26 19:07:44 UTC (rev 550)
@@ -1,15 +1,27 @@
--------------------------
O p e n u t i l s
--------------------------
- Fabrizio Giustina
+ Fabrizio Giustina
--------------------------
openutils-testing
+ Openutils-testing extends the standard spring testing framework by providing more high-level base testing classes and utils.
+ In particular, it provides a {{{dbunit.html}framework for using with dbunit in Spring test cases}}.
+ The openutils-testing jar only contains generic classes that don't depends on any specific test framework. You should
+ depend on openutils-testing-testng or openutils-testing-junit
+
+
Released versions
- Check it at {{{http://www.mvnrepository.com/artifact/net.sourceforge.openutils/openutils-testing}http://www.mvnrepository.com/artifact/net.sourceforge.openutils/openutils-testing}}
+ openutils-testing-testng:
+ {{{http://www.mvnrepository.com/artifact/net.sourceforge.openutils/openutils-testing-testng}http://www.mvnrepository.com/artifact/net.sourceforge.openutils/openutils-testing-testng}}
+
+ openutils-testing-junit:
+
+ {{{http://www.mvnrepository.com/artifact/net.sourceforge.openutils/openutils-testing-junit}http://www.mvnrepository.com/artifact/net.sourceforge.openutils/openutils-testing-junit}}
+
Added: trunk/openutils-testing-junit/src/site/apt/index.apt
===================================================================
--- trunk/openutils-testing-junit/src/site/apt/index.apt (rev 0)
+++ trunk/openutils-testing-junit/src/site/apt/index.apt 2008-01-26 19:07:44 UTC (rev 550)
@@ -0,0 +1,20 @@
+ --------------------------
+ O p e n u t i l s
+ --------------------------
+ Fabrizio Giustina
+ --------------------------
+
+openutils-testing-junit
+
+ openutils-testing-junit is a junit specific extension of openutils-testing.
+
+ See {{{../openutils-testing/}openutils-testing}} for documentation.
+
+
+
+Released versions
+
+ openutils-testing-junit:
+
+ {{{http://www.mvnrepository.com/artifact/net.sourceforge.openutils/openutils-testing-junit}http://www.mvnrepository.com/artifact/net.sourceforge.openutils/openutils-testing-junit}}
+
Property changes on: trunk/openutils-testing-junit/src/site/apt/index.apt
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: trunk/openutils-testing-testng/src/site/apt/index.apt
===================================================================
--- trunk/openutils-testing-testng/src/site/apt/index.apt (rev 0)
+++ trunk/openutils-testing-testng/src/site/apt/index.apt 2008-01-26 19:07:44 UTC (rev 550)
@@ -0,0 +1,17 @@
+ --------------------------
+ O p e n u t i l s
+ --------------------------
+ Fabrizio Giustina
+ --------------------------
+
+openutils-testing-testng
+
+ openutils-testing-testng is a testng specific extension of openutils-testing.
+
+ See {{{../openutils-testing/}openutils-testing}} for documentation.
+
+
+
+Released versions
+
+ {{{http://www.mvnrepository.com/artifact/net.sourceforge.openutils/openutils-testing-testng}http://www.mvnrepository.com/artifact/net.sourceforge.openutils/openutils-testing-testng}}
Property changes on: trunk/openutils-testing-testng/src/site/apt/index.apt
___________________________________________________________________
Name: svn:executable
+ *
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-03-02 23:28:12
|
Revision: 711
http://openutils.svn.sourceforge.net/openutils/?rev=711&view=rev
Author: fgiust
Date: 2008-03-02 15:28:17 -0800 (Sun, 02 Mar 2008)
Log Message:
-----------
fix excludedTables in DbUnitExecution
Modified Paths:
--------------
trunk/openutils-testing/pom.xml
trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitExecution.java
trunk/openutils-testing/src/site/changes/changes.xml
Added Paths:
-----------
trunk/openutils-testing/src/test/
trunk/openutils-testing/src/test/java/
trunk/openutils-testing/src/test/java/it/
trunk/openutils-testing/src/test/java/it/openutils/
trunk/openutils-testing/src/test/java/it/openutils/testing/
trunk/openutils-testing/src/test/java/it/openutils/testing/RegExpTableFilterTest.java
Property Changed:
----------------
trunk/openutils-testing/
Property changes on: trunk/openutils-testing
___________________________________________________________________
Name: svn:ignore
- .project
.classpath
.checkstyle
target
.settings
+ .project
.classpath
.checkstyle
target
.settings
test-output
temp-testng-customsuite.xml
Modified: trunk/openutils-testing/pom.xml
===================================================================
--- trunk/openutils-testing/pom.xml 2008-02-29 16:53:04 UTC (rev 710)
+++ trunk/openutils-testing/pom.xml 2008-03-02 23:28:17 UTC (rev 711)
@@ -1,4 +1,5 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>net.sourceforge.openutils</groupId>
@@ -57,6 +58,19 @@
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <classifier>jdk15</classifier>
+ <version>5.7</version>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
</dependencies>
<properties>
<spring.version>2.5.1</spring.version>
Modified: trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitExecution.java
===================================================================
--- trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitExecution.java 2008-02-29 16:53:04 UTC (rev 710)
+++ trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitExecution.java 2008-03-02 23:28:17 UTC (rev 711)
@@ -22,7 +22,6 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
-import org.dbunit.database.DatabaseConfig;
import org.dbunit.dataset.datatype.IDataTypeFactory;
import org.dbunit.operation.DatabaseOperation;
@@ -62,9 +61,9 @@
/**
* A regexp that can match table names. Any table matching this regular expression will not be considered by DbUnit.
- * By default tables starting with $ are ignored (oracle recycle bin).
+ * By default tables starting with BIN$ are ignored (oracle recycle bin).
*/
- String excludedTables() default "(^\\$(.*))"; // oracle recycle bin
+ String excludedTables() default "^BIN\\$(.*)"; // oracle recycle bin
/**
* If true, <strong>all</strong> the tables in the database will be truncated before loading any dataset.
Modified: trunk/openutils-testing/src/site/changes/changes.xml
===================================================================
--- trunk/openutils-testing/src/site/changes/changes.xml 2008-02-29 16:53:04 UTC (rev 710)
+++ trunk/openutils-testing/src/site/changes/changes.xml 2008-03-02 23:28:17 UTC (rev 711)
@@ -8,30 +8,30 @@
<author email="fgiust(at)users.sourceforge.net">Fabrizio Giustina</author>
</properties>
<body>
+ <release version="2.0.3" date="in svn" description="2.0.3">
+ <action type="fix" dev="fgiust"> excludedTables in DbUnitExecution now defaults to "^BIN\\$(.*)", properly excluding
+ tables in oracle recycle bin.</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>
+ <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 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>
+ <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>
<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">
- (junit version only). it.openutils.testing.junit.AbstractDbUnitJunitSpringContextTests was totally broken due to
- the setup method being protected. Fixed + added tests
- </action>
+ <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>
Added: trunk/openutils-testing/src/test/java/it/openutils/testing/RegExpTableFilterTest.java
===================================================================
--- trunk/openutils-testing/src/test/java/it/openutils/testing/RegExpTableFilterTest.java (rev 0)
+++ trunk/openutils-testing/src/test/java/it/openutils/testing/RegExpTableFilterTest.java 2008-03-02 23:28:17 UTC (rev 711)
@@ -0,0 +1,26 @@
+package it.openutils.testing;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+
+/**
+ * @author fgiust
+ * @version $Id: $
+ */
+@DbUnitExecution
+public class RegExpTableFilterTest
+{
+
+ @Test
+ public void testDefaultRegExp() throws Exception
+ {
+
+ DbUnitExecution dbUnitExecution = getClass().getAnnotation(DbUnitExecution.class);
+ RegExpTableFilter retf = new RegExpTableFilter(dbUnitExecution.excludedTables());
+
+ Assert.assertTrue(retf.accept("SOMETHING"));
+ Assert.assertFalse(retf.accept("BIN$SOMETHING"));
+
+ }
+}
Property changes on: trunk/openutils-testing/src/test/java/it/openutils/testing/RegExpTableFilterTest.java
___________________________________________________________________
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-04-27 09:51:46
|
Revision: 753
http://openutils.svn.sourceforge.net/openutils/?rev=753&view=rev
Author: fgiust
Date: 2008-04-27 02:51:42 -0700 (Sun, 27 Apr 2008)
Log Message:
-----------
cleanup deprecations for 2.1
Modified Paths:
--------------
trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitTestContext.java
trunk/openutils-testing-junit/src/main/java/it/openutils/testing/junit/AbstractDbUnitJunitSpringContextTests.java
trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/AbstractDbUnitTestNGSpringContextTests.java
Removed Paths:
-------------
trunk/openutils-testing-junit/src/main/java/it/openutils/testing/junit/DbUnitTestCase.java
trunk/openutils-testing-junit/src/main/java/it/openutils/testing/junit/GenericsDbUnitTestCase.java
trunk/openutils-testing-junit/src/main/java/it/openutils/testing/junit/SpringTestCase.java
trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/DbUnitTestCase.java
trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/GenericsDbUnitTestCase.java
trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/SpringTestCase.java
trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/utils/
Modified: trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitTestContext.java
===================================================================
--- trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitTestContext.java 2008-04-27 09:45:03 UTC (rev 752)
+++ trunk/openutils-testing/src/main/java/it/openutils/testing/DbUnitTestContext.java 2008-04-27 09:51:42 UTC (rev 753)
@@ -96,7 +96,6 @@
* Setup the Database before running the test method.
* @throws Exception Any exception.
*/
- @SuppressWarnings("unchecked")
public void setUpDbUnit() throws Exception
{
DbUnitExecution singleDbUnitExecution = testcase.getClass().getAnnotation(DbUnitExecution.class);
Modified: trunk/openutils-testing-junit/src/main/java/it/openutils/testing/junit/AbstractDbUnitJunitSpringContextTests.java
===================================================================
--- trunk/openutils-testing-junit/src/main/java/it/openutils/testing/junit/AbstractDbUnitJunitSpringContextTests.java 2008-04-27 09:45:03 UTC (rev 752)
+++ trunk/openutils-testing-junit/src/main/java/it/openutils/testing/junit/AbstractDbUnitJunitSpringContextTests.java 2008-04-27 09:51:42 UTC (rev 753)
@@ -44,7 +44,6 @@
* Setup the Database before running the test method.
* @throws Exception Any exception.
*/
- @SuppressWarnings("unchecked")
@Before
public void setUpDbUnit() throws Exception
{
Deleted: trunk/openutils-testing-junit/src/main/java/it/openutils/testing/junit/DbUnitTestCase.java
===================================================================
--- trunk/openutils-testing-junit/src/main/java/it/openutils/testing/junit/DbUnitTestCase.java 2008-04-27 09:45:03 UTC (rev 752)
+++ trunk/openutils-testing-junit/src/main/java/it/openutils/testing/junit/DbUnitTestCase.java 2008-04-27 09:51:42 UTC (rev 753)
@@ -1,269 +0,0 @@
-/*
- * 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.junit;
-
-import java.io.InputStream;
-import java.sql.SQLException;
-import java.util.Map;
-
-import javax.sql.DataSource;
-
-import org.apache.commons.lang.ClassUtils;
-import org.apache.commons.lang.StringUtils;
-import org.dbunit.database.DatabaseConnection;
-import org.dbunit.database.DatabaseSequenceFilter;
-import org.dbunit.database.IDatabaseConnection;
-import org.dbunit.dataset.DataSetException;
-import org.dbunit.dataset.FilteredDataSet;
-import org.dbunit.dataset.IDataSet;
-import org.dbunit.dataset.excel.XlsDataSet;
-import org.dbunit.dataset.filter.AbstractTableFilter;
-import org.dbunit.dataset.filter.ITableFilter;
-import org.dbunit.dataset.filter.SequenceTableFilter;
-import org.dbunit.dataset.xml.XmlDataSet;
-import org.dbunit.ext.mssql.InsertIdentityOperation;
-import org.dbunit.operation.DatabaseOperation;
-import org.hibernate.SessionFactory;
-import org.springframework.orm.hibernate3.SessionHolder;
-import org.springframework.transaction.support.TransactionSynchronizationManager;
-
-
-/**
- * Base class for running DAO tests.
- * @author fgiust
- * @version $Revision $ ($Author $)
- * @deprecated use {@link AbstractDbUnitJunitSpringContextTests}
- */
-@Deprecated
-public abstract class DbUnitTestCase extends SpringTestCase
-{
-
- /**
- * Hibernate session factory.
- */
- private SessionFactory sessionFactory;
-
- private static final String BASETEST_DELETE = "/_BaseDAOTest-delete.xml";
-
- protected static IDataSet truncateDataSet;
-
- /**
- * Should use deferred close emulating the spring OpenSessionInView filter? Default is <code>true</code>
- * @return <code>true</code> if deferred close should be used
- */
- protected boolean mimicSessionFilter()
- {
- return true;
- }
-
- /**
- * Returns the table filter that will be used to exclude certain tables from sort/deletion. This may be overridden
- * by subclasses, and is needed when tables have circular references (not handled by dbunit DatabaseSequenceFilter)
- * @return an <code>ITableFilter</code>
- */
- protected ITableFilter getTableFilter()
- {
- return new AbstractTableFilter()
- {
-
- @Override
- public boolean isValidName(String tableName) throws DataSetException
- {
- // default excludes:
- // $ = oracle recycle bin tables
- // JBPM = jbpm tables, with circular references
- return !StringUtils.contains(tableName, "$") && !StringUtils.contains(tableName, "JBPM");
- }
- };
- }
-
- /**
- * {@inheritDoc}
- */
- @SuppressWarnings("unchecked")
- @Override
- protected void setUp() throws Exception
- {
- super.setUp();
-
- // insert values
- IDataSet dataSet = null;
-
- String datesetFileName = "/" + ClassUtils.getShortClassName(getClass()) + "-load.xml";
- InputStream testData = getClass().getResourceAsStream(datesetFileName);
-
- if (testData != null)
- {
- if (log.isDebugEnabled())
- {
- log.debug("loading dataset {}", datesetFileName);
- }
-
- dataSet = new XmlDataSet(testData);
- }
- else
- {
- // check for excel
- datesetFileName = "/" + ClassUtils.getShortClassName(getClass()) + "-load.xls";
- testData = getClass().getResourceAsStream(datesetFileName);
-
- if (testData != null)
- {
- if (log.isDebugEnabled())
- {
- log.debug("loading dataset {}", datesetFileName);
- }
-
- dataSet = new XlsDataSet(testData);
- }
- }
-
- if (dataSet == null)
- {
- log.debug("No test data found with name [{}]", datesetFileName);
- }
- else
- {
-
- IDatabaseConnection connection = createConnection();
-
- // truncate common tables
- if (truncateDataSet == null)
- {
- log.debug("Generating sorted dataset for initial cleanup");
- IDataSet unsortedTruncateDataSet = connection.createDataSet();
-
- ITableFilter filter = new DatabaseSequenceFilter(connection, new FilteredDataSet(
- getTableFilter(),
- unsortedTruncateDataSet).getTableNames());
- truncateDataSet = new FilteredDataSet(filter, unsortedTruncateDataSet);
- truncateDataSet = new FilteredDataSet(getTableFilter(), truncateDataSet);
- log.debug("Sorted dataset generated");
- }
-
- IDataSet orderedDataset = dataSet;
-
- // if a sorted dataset is available, use table sequence for sorting
- if (truncateDataSet != null)
- {
- ITableFilter filter = new SequenceTableFilter(truncateDataSet.getTableNames());
- orderedDataset = new FilteredDataSet(filter, dataSet);
- }
-
- try
- {
- if (truncateDataSet != null)
- {
- DatabaseOperation.DELETE_ALL.execute(connection, truncateDataSet);
- }
- if (dataSet != null)
- {
- InsertIdentityOperation.INSERT.execute(connection, orderedDataset);
- }
- }
- finally
- {
- connection.close();
- }
- }
-
- // mimic the Spring OpenSessionInViewFilter
- if (mimicSessionFilter())
- {
- Map<String, SessionFactory> sfbeans = ctx.getBeansOfType(SessionFactory.class);
- if (sfbeans.isEmpty())
- {
- fail("No bean of type org.hibernate.SessionFactory found in spring context");
- }
- this.sessionFactory = sfbeans.get(sfbeans.keySet().iterator().next());
-
- TransactionSynchronizationManager.bindResource(this.getSessionFactory(), new SessionHolder(this
- .getSessionFactory()
- .openSession()));
- }
-
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected void tearDown() throws Exception
- {
- if (mimicSessionFilter())
- {
- // close open hibernate sessions, mimic the OpenSessionInViewFilter
- if (TransactionSynchronizationManager.hasResource(this.getSessionFactory()))
- {
- TransactionSynchronizationManager.unbindResource(this.getSessionFactory());
- }
- }
-
- // regenerate db initial state
- String datesetFileName = "/initial-load.xml";
- InputStream testData = getClass().getResourceAsStream(datesetFileName);
-
- if (testData != null)
- {
- log.debug("Restoring db state");
-
- IDataSet dataSet = new XmlDataSet(testData);
-
- DataSource dataSource = (DataSource) ctx.getBean("dataSource");
- IDatabaseConnection connection = new DatabaseConnection(dataSource.getConnection());
-
- try
- {
- DatabaseOperation.CLEAN_INSERT.execute(connection, dataSet);
- }
- finally
- {
- connection.close();
- }
- }
-
- super.tearDown();
- }
-
- /**
- * Returns the full test name.
- * @see junit.framework.TestCase#getName()
- */
- @Override
- public String getName()
- {
- return ClassUtils.getShortClassName(this.getClass()) + "::" + super.getName();
- }
-
- /**
- * @return The IDatabase connection to use to insert data
- * @throws SQLException Thrown on any database connection error
- */
- protected IDatabaseConnection createConnection() throws SQLException
- {
- DataSource dataSource = (DataSource) ctx.getBean("dataSource");
- return new DatabaseConnection(dataSource.getConnection());
- }
-
- /**
- * return the current Hibernate SessionFactory
- * @return SessionFactory object
- */
- protected SessionFactory getSessionFactory()
- {
- return sessionFactory;
- }
-}
\ No newline at end of file
Deleted: trunk/openutils-testing-junit/src/main/java/it/openutils/testing/junit/GenericsDbUnitTestCase.java
===================================================================
--- trunk/openutils-testing-junit/src/main/java/it/openutils/testing/junit/GenericsDbUnitTestCase.java 2008-04-27 09:45:03 UTC (rev 752)
+++ trunk/openutils-testing-junit/src/main/java/it/openutils/testing/junit/GenericsDbUnitTestCase.java 2008-04-27 09:51:42 UTC (rev 753)
@@ -1,55 +0,0 @@
-/*
- * 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.junit;
-
-import java.lang.reflect.ParameterizedType;
-
-import org.apache.commons.lang.ClassUtils;
-import org.apache.commons.lang.StringUtils;
-
-
-/**
- * @param <D> Spring-managed bean under test. Warning, this base class expect that the name of the bean is the
- * non-qualified lowercase class name of the object. For example the bean name for
- * <code>org.something.MyNiceComponent</code> is expected to be <code>myNiceComponent</code>. The bean obtained
- * from Spring is made available through the <code>instance</code> protected field.
- * @author fgiust
- * @version $Id$
- * @deprecated use {@link AbstractDbUnitJunitSpringContextTests}
- */
-@Deprecated
-public class GenericsDbUnitTestCase<D> extends DbUnitTestCase
-{
-
- /**
- * Test instance.
- */
- protected D instance;
-
- /**
- * Load the tested bean from Spring application context.
- */
- @Override
- @SuppressWarnings("unchecked")
- protected void setUp() throws Exception
- {
- super.setUp();
- String genericClass = ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0]
- .toString();
-
- instance = (D) ctx.getBean(StringUtils.uncapitalize(ClassUtils.getShortClassName(genericClass)));
- }
-}
Deleted: trunk/openutils-testing-junit/src/main/java/it/openutils/testing/junit/SpringTestCase.java
===================================================================
--- trunk/openutils-testing-junit/src/main/java/it/openutils/testing/junit/SpringTestCase.java 2008-04-27 09:45:03 UTC (rev 752)
+++ trunk/openutils-testing-junit/src/main/java/it/openutils/testing/junit/SpringTestCase.java 2008-04-27 09:51:42 UTC (rev 753)
@@ -1,67 +0,0 @@
-/*
- * 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.junit;
-
-import junit.framework.TestCase;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-
-
-/**
- * Base class for running spring-based tests.
- * @author fgiust
- * @version $Revision $ ($Author $)
- * @deprecated {@link org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests}
- */
-@Deprecated
-public abstract class SpringTestCase extends TestCase
-{
-
- /**
- * Default Spring context initilization file used for tests.
- */
- private static final String DEFAULT_TEST_CONTEXT_FILE = "/spring-tests.xml";
-
- /**
- * Spring application context.
- */
- protected static ApplicationContext ctx;
-
- /**
- * logger. Not static so it can be reused in tests
- */
- protected Logger log = LoggerFactory.getLogger(getClass());
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected void setUp() throws Exception
- {
-
- if (ctx == null)
- {
- // load Spring's BeanFactory
- String[] paths = {DEFAULT_TEST_CONTEXT_FILE };
- ctx = new ClassPathXmlApplicationContext(paths);
- }
-
- }
-
-}
\ No newline at end of file
Modified: trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/AbstractDbUnitTestNGSpringContextTests.java
===================================================================
--- trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/AbstractDbUnitTestNGSpringContextTests.java 2008-04-27 09:45:03 UTC (rev 752)
+++ trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/AbstractDbUnitTestNGSpringContextTests.java 2008-04-27 09:51:42 UTC (rev 753)
@@ -44,7 +44,6 @@
* Setup the Database before running the test method.
* @throws Exception Any exception.
*/
- @SuppressWarnings("unchecked")
@BeforeMethod
protected void setUpDbUnit() throws Exception
{
Deleted: trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/DbUnitTestCase.java
===================================================================
--- trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/DbUnitTestCase.java 2008-04-27 09:45:03 UTC (rev 752)
+++ trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/DbUnitTestCase.java 2008-04-27 09:51:42 UTC (rev 753)
@@ -1,306 +0,0 @@
-/*
- * 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.testng;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.sql.SQLException;
-import java.text.MessageFormat;
-import java.util.Map;
-
-import javax.sql.DataSource;
-
-import org.apache.commons.lang.ArrayUtils;
-import org.apache.commons.lang.ClassUtils;
-import org.apache.commons.lang.StringUtils;
-import org.dbunit.DatabaseUnitException;
-import org.dbunit.database.DatabaseConnection;
-import org.dbunit.database.DatabaseSequenceFilter;
-import org.dbunit.database.IDatabaseConnection;
-import org.dbunit.dataset.DataSetException;
-import org.dbunit.dataset.FilteredDataSet;
-import org.dbunit.dataset.IDataSet;
-import org.dbunit.dataset.excel.XlsDataSet;
-import org.dbunit.dataset.filter.AbstractTableFilter;
-import org.dbunit.dataset.filter.ITableFilter;
-import org.dbunit.dataset.filter.SequenceTableFilter;
-import org.dbunit.dataset.xml.XmlDataSet;
-import org.dbunit.operation.DatabaseOperation;
-import org.hibernate.SessionFactory;
-import org.testng.Assert;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-import org.springframework.orm.hibernate3.SessionHolder;
-import org.springframework.transaction.support.TransactionSynchronizationManager;
-
-
-/**
- * @author fgiust
- * @version $Id$
- * @deprecated use {@link AbstractDbUnitTestNGSpringContextTests}
- */
-@Test
-@Deprecated
-public class DbUnitTestCase extends SpringTestCase
-{
-
- /**
- * name for the dataSource bean in Spring context.
- */
- private static final String DATASOURCE_BEAN_NAME = "dataSource";
-
- /**
- * Pattern for dbunit file loaded before a test. MessageFormat format with two placeholders: class name and
- * extension.
- */
- private static final String DATAFILE_PATTERN = "/{0}-load.{1}";
-
- protected static IDataSet truncateDataSet;
-
- /**
- * Hibernate session factory.
- */
- private SessionFactory sessionFactory;
-
- /**
- * Optional schema (needed for ORACLE).
- * @return <code>null</code>
- */
- protected String getSchema()
- {
- return null;
- }
-
- /**
- * Should use deferred close emulating the spring OpenSessionInView filter? Default is <code>true</code>
- * @return <code>true</code> if deferred close should be used
- */
- protected boolean mimicSessionFilter()
- {
- return true;
- }
-
- /**
- * Returns the table filter that will be used to exclude certain tables from sort/deletion. This may be overridden
- * by subclasses, and is needed when tables have circular references (not handled by dbunit DatabaseSequenceFilter)
- * @return an <code>ITableFilter</code>
- */
- protected ITableFilter getTableFilter()
- {
- return new AbstractTableFilter()
- {
-
- @Override
- public boolean isValidName(String tableName) throws DataSetException
- {
- // default excludes:
- // $ = oracle recycle bin tables
- // JBPM = jbpm tables, with circular references
- return !StringUtils.contains(tableName, "$") && !StringUtils.contains(tableName, "JBPM");
- }
- };
- }
-
- /**
- * Setup the Database before running the test method.
- * @throws Exception Any exception.
- */
- @SuppressWarnings("unchecked")
- @BeforeMethod
- protected void setUpDbUnit() throws Exception
- {
- // mimic the Spring OpenSessionInViewFilter
- if (mimicSessionFilter())
- {
- Map<String, SessionFactory> sfbeans = ctx.getBeansOfType(SessionFactory.class);
- if (sfbeans.isEmpty())
- {
- Assert.fail("No bean of type org.hibernate.SessionFactory found in spring context");
- }
- this.sessionFactory = sfbeans.get(sfbeans.keySet().iterator().next());
-
- TransactionSynchronizationManager.bindResource(this.sessionFactory, new SessionHolder(this.sessionFactory
- .openSession()));
- }
-
- // check for xml
- IDataSet dataSet = loadDataSet(getDataFileName("xml"));
-
- if (dataSet == null)
- {
- // check for excel
- dataSet = loadDataSet(getDataFileName("xls"));
- }
-
- if (dataSet != null)
- {
- importDataSet(dataSet);
- }
- else
- {
- log.debug("No test data found with name [{}]", getDataFileName("xml/xls"));
- }
- }
-
- /**
- * Exports a database to an Excel file
- * @param fileName The file name we save the Excel dump to.
- * @throws IOException An IO Exception.
- * @throws DataSetException A dataset exception.
- * @throws SQLException A SQL Exception.
- */
- protected void exportDbToXls(String fileName) throws IOException, DataSetException, SQLException
- {
- IDatabaseConnection connection = getDbUnitConnection();
-
- IDataSet fullDataSet = connection.createDataSet();
-
- File outFile = new File(fileName);
- OutputStream fos = new FileOutputStream(outFile);
- XlsDataSet.write(fullDataSet, fos);
- fos.close();
- }
-
- /**
- * Cleans the database after we run the tests.
- * @throws Exception Any exception.
- */
- @AfterMethod
- protected void tearDownDbUnit() throws Exception
- {
- if (mimicSessionFilter())
- {
- // close open hibernate sessions, mimic the OpenSessionInViewFilter
- // close open hibernate sessions, mimic the OpenSessionInViewFilter
- if (TransactionSynchronizationManager.hasResource(this.sessionFactory))
- {
- TransactionSynchronizationManager.unbindResource(this.sessionFactory);
- }
- }
-
- // regenerate db initial state
- String datesetFileName = "/initial-load.xml";
- InputStream testData = getClass().getResourceAsStream(datesetFileName);
-
- if (testData != null)
- {
- log.debug("Restoring db state");
-
- IDataSet dataSet = new XmlDataSet(testData);
-
- IDatabaseConnection connection = getDbUnitConnection();
-
- try
- {
- DatabaseOperation.CLEAN_INSERT.execute(connection, dataSet);
- }
- finally
- {
- connection.close();
- }
- }
- }
-
- private void importDataSet(IDataSet dataSet) throws SQLException, DataSetException, DatabaseUnitException
- {
- IDatabaseConnection connection = getDbUnitConnection();
-
- if (truncateDataSet == null)
- {
- log.debug("Generating sorted dataset for initial cleanup");
- IDataSet unsortedTruncateDataSet = connection.createDataSet();
-
- ITableFilter filter = new DatabaseSequenceFilter(connection, new FilteredDataSet(
- getTableFilter(),
- unsortedTruncateDataSet).getTableNames());
- truncateDataSet = new FilteredDataSet(filter, unsortedTruncateDataSet);
- truncateDataSet = new FilteredDataSet(getTableFilter(), truncateDataSet);
- log.debug("Sorted dataset generated");
- }
-
- IDataSet orderedDataset = new FilteredDataSet(new AbstractTableFilter()
- {
-
- @Override
- public boolean isValidName(String tableName) throws DataSetException
- {
- return !StringUtils.contains(tableName, "$");
- }
- }, dataSet);
-
- log.debug("Tables: {}", ArrayUtils.toString(orderedDataset.getTableNames()));
- log.debug("Tables truncateDataSet: {}", ArrayUtils.toString(truncateDataSet.getTableNames()));
-
- // if a sorted dataset is available, use table sequence for sorting
- if (truncateDataSet != null)
- {
- ITableFilter filter = new SequenceTableFilter(truncateDataSet.getTableNames());
- orderedDataset = new FilteredDataSet(filter, dataSet);
- }
-
- try
- {
-
- if (truncateDataSet != null)
- {
- DatabaseOperation.DELETE_ALL.execute(connection, truncateDataSet);
- }
- if (dataSet != null)
- {
- DatabaseOperation.INSERT.execute(connection, orderedDataset);
- }
- }
- finally
- {
- connection.close();
- }
- }
-
- /**
- * @return
- * @throws SQLException
- */
- private IDatabaseConnection getDbUnitConnection() throws SQLException
- {
- DataSource dataSource = (DataSource) ctx.getBean(DATASOURCE_BEAN_NAME);
- IDatabaseConnection connection = new DatabaseConnection(dataSource.getConnection(), getSchema());
- return connection;
- }
-
- private String getDataFileName(String extension)
- {
- return MessageFormat.format(DATAFILE_PATTERN, ClassUtils.getShortClassName(getClass()), extension);
- }
-
- private IDataSet loadDataSet(String datesetFile) throws IOException, DataSetException
- {
- InputStream is = getClass().getResourceAsStream(datesetFile);
- IDataSet dataSet = null;
-
- if (is != null)
- {
- log.debug("loading dataset {}", datesetFile);
- dataSet = datesetFile.endsWith(".xls") ? new XlsDataSet(is) : new XmlDataSet(is);
- is.close();
- }
-
- return dataSet;
- }
-}
Deleted: trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/GenericsDbUnitTestCase.java
===================================================================
--- trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/GenericsDbUnitTestCase.java 2008-04-27 09:45:03 UTC (rev 752)
+++ trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/GenericsDbUnitTestCase.java 2008-04-27 09:51:42 UTC (rev 753)
@@ -1,57 +0,0 @@
-/*
- * 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.testng;
-
-import java.lang.reflect.ParameterizedType;
-
-import org.apache.commons.lang.ClassUtils;
-import org.apache.commons.lang.StringUtils;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-
-/**
- * @param <D> Spring-managed bean under test. Warning, this base class expect that the name of the bean is the
- * non-qualified lowercase class name of the object. For example the bean name for
- * <code>org.something.MyNiceComponent</code> is expected to be <code>myNiceComponent</code>. The bean obtained
- * from Spring is made available through the <code>instance</code> protected field.
- * @author fgiust
- * @version $Id$
- * @deprecated use {@link AbstractDbUnitTestNGSpringContextTests}
- */
-@Test
-@Deprecated
-public class GenericsDbUnitTestCase<D> extends DbUnitTestCase
-{
-
- /**
- * Test instance.
- */
- protected D instance;
-
- /**
- * Load the tested bean from Spring application context.
- */
- @SuppressWarnings("unchecked")
- @BeforeClass
- protected void setUp()
- {
- String genericClass = ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0]
- .toString();
-
- instance = (D) ctx.getBean(StringUtils.uncapitalize(ClassUtils.getShortClassName(genericClass)));
- }
-}
Deleted: trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/SpringTestCase.java
===================================================================
--- trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/SpringTestCase.java 2008-04-27 09:45:03 UTC (rev 752)
+++ trunk/openutils-testing-testng/src/main/java/it/openutils/testing/testng/SpringTestCase.java 2008-04-27 09:51:42 UTC (rev 753)
@@ -1,90 +0,0 @@
-/*
- * 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.testng;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-
-/**
- * Base class for running spring-based tests.
- * @author fgiust
- * @version $Revision $ ($Author $)
- * @deprecated {@link org.springframework.test.context.testng.AbstractTestNGSpringContextTests}
- */
-@Test
-@Deprecated
-public abstract class SpringTestCase
-{
-
- /**
- * Default Spring context initilization file used for tests.
- */
- public static final String DEFAULT_TEST_CONTEXT_FILE = "/spring-tests.xml";
-
- /**
- * Spring application context.
- */
- protected static ApplicationContext ctx;
-
- /**
- * logger. Not static so it can be reused in tests
- */
- protected Logger log = LoggerFactory.getLogger(getClass());
-
- /**
- * Setup Spring application context, by loading the <code>/spring-tests.xml</code> file from the classpath.
- * @throws Exception
- */
- @BeforeClass
- protected void setUpSpring()
- {
-
- if (ctx == null)
- {
- // load Spring's BeanFactory
- String[] paths = {DEFAULT_TEST_CONTEXT_FILE };
- ctx = new ClassPathXmlApplicationContext(paths)
- {
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected void initBeanDefinitionReader(XmlBeanDefinitionReader beanDefinitionReader)
- {
- initAppContextBeanDefinitionReader(beanDefinitionReader);
- }
- };
- }
- }
-
- /**
- * You can override this method if you need to pass a custom documentReaderClass to the spring bean definition
- * reader.
- * @param beanDefinitionReader XmlBeanDefinitionReader instance
- */
- protected void initAppContextBeanDefinitionReader(XmlBeanDefinitionReader beanDefinitionReader)
- {
- // you can subclass this method if needed
- }
-
-}
\ No newline at end of file
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:55:10
|
Revision: 754
http://openutils.svn.sourceforge.net/openutils/?rev=754&view=rev
Author: fgiust
Date: 2008-04-27 02:55:10 -0700 (Sun, 27 Apr 2008)
Log Message:
-----------
one more
Modified Paths:
--------------
trunk/openutils-testing/pom.xml
trunk/openutils-testing/src/site/changes/changes.xml
Modified: trunk/openutils-testing/pom.xml
===================================================================
--- trunk/openutils-testing/pom.xml 2008-04-27 09:51:42 UTC (rev 753)
+++ trunk/openutils-testing/pom.xml 2008-04-27 09:55:10 UTC (rev 754)
@@ -15,17 +15,17 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
- <version>1.4.1</version>
+ <version>1.5.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl104-over-slf4j</artifactId>
- <version>1.4.1</version>
+ <version>1.5.0</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
- <version>2.3</version>
+ <version>2.4</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
@@ -73,6 +73,6 @@
</dependency>
</dependencies>
<properties>
- <spring.version>2.5.1</spring.version>
+ <spring.version>2.5.3</spring.version>
</properties>
</project>
\ No newline at end of file
Modified: trunk/openutils-testing/src/site/changes/changes.xml
===================================================================
--- trunk/openutils-testing/src/site/changes/changes.xml 2008-04-27 09:51:42 UTC (rev 753)
+++ trunk/openutils-testing/src/site/changes/changes.xml 2008-04-27 09:55:10 UTC (rev 754)
@@ -8,9 +8,10 @@
<author email="fgiust(at)users.sourceforge.net">Fabrizio Giustina</author>
</properties>
<body>
- <release version="2.1" date="in svn" description="2.1">
+ <release version="2.1" date="2008-04-27" 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="update" dev="fgiust">Updated spring, slf4j and commons-lang dependencies</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
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fg...@us...> - 2008-04-27 12:20:42
|
Revision: 763
http://openutils.svn.sourceforge.net/openutils/?rev=763&view=rev
Author: fgiust
Date: 2008-04-27 05:20:46 -0700 (Sun, 27 Apr 2008)
Log Message:
-----------
cleanup poms
Modified Paths:
--------------
trunk/openutils-testing/pom.xml
trunk/openutils-testing-junit/pom.xml
trunk/openutils-testing-testng/pom.xml
Modified: trunk/openutils-testing/pom.xml
===================================================================
--- trunk/openutils-testing/pom.xml 2008-04-27 12:05:52 UTC (rev 762)
+++ trunk/openutils-testing/pom.xml 2008-04-27 12:20:46 UTC (rev 763)
@@ -39,6 +39,36 @@
</exclusions>
</dependency>
<dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-test</artifactId>
+ <version>${spring.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-core</artifactId>
+ <version>${spring.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
<groupId>org.dbunit</groupId>
<artifactId>dbunit</artifactId>
<version>2.2</version>
Modified: trunk/openutils-testing-junit/pom.xml
===================================================================
--- trunk/openutils-testing-junit/pom.xml 2008-04-27 12:05:52 UTC (rev 762)
+++ trunk/openutils-testing-junit/pom.xml 2008-04-27 12:20:46 UTC (rev 763)
@@ -27,69 +27,36 @@
<artifactId>commons-logging</artifactId>
</exclusion>
<exclusion>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </exclusion>
+ <exclusion>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- <version>1.5.0</version>
- </dependency>
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- <version>1.2.13</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-core</artifactId>
- <version>${spring.version}</version>
+ <groupId>org.dbunit</groupId>
+ <artifactId>dbunit</artifactId>
+ <version>2.2</version>
+ <optional>true</optional>
<exclusions>
<exclusion>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
</exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-context</artifactId>
- <version>${spring.version}</version>
- <exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-orm</artifactId>
- <version>${spring.version}</version>
- <optional>true</optional>
- <exclusions>
<exclusion>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
+ <groupId>junit-addons</groupId>
+ <artifactId>junit-addons</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
- <groupId>org.dbunit</groupId>
- <artifactId>dbunit</artifactId>
- <version>2.2</version>
- <optional>true</optional>
- <exclusions>
- <exclusion>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.4</version>
Modified: trunk/openutils-testing-testng/pom.xml
===================================================================
--- trunk/openutils-testing-testng/pom.xml 2008-04-27 12:05:52 UTC (rev 762)
+++ trunk/openutils-testing-testng/pom.xml 2008-04-27 12:20:46 UTC (rev 763)
@@ -1,4 +1,5 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>net.sourceforge.openutils</groupId>
@@ -17,80 +18,6 @@
<version>2.1</version>
</dependency>
<dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-test</artifactId>
- <version>${spring.version}</version>
- <exclusions>
- <exclusion>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- </exclusion>
- <exclusion>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- <version>1.5.0</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-core</artifactId>
- <version>${spring.version}</version>
- <exclusions>
- <exclusion>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-context</artifactId>
- <version>${spring.version}</version>
- <exclusions>
- <exclusion>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-orm</artifactId>
- <version>${spring.version}</version>
- <optional>true</optional>
- <exclusions>
- <exclusion>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.dbunit</groupId>
- <artifactId>dbunit</artifactId>
- <version>2.2</version>
- <optional>true</optional>
- <exclusions>
- <exclusion>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </exclusion>
- <exclusion>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- </exclusion>
- <exclusion>
- <groupId>junit-addons</groupId>
- <artifactId>junit-addons</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<classifier>jdk15</classifier>
@@ -103,22 +30,6 @@
</exclusions>
</dependency>
<dependency>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate</artifactId>
- <version>3.2.1.ga</version>
- <optional>true</optional>
- <exclusions>
- <exclusion>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- </exclusion>
- <exclusion>
- <groupId>cglib</groupId>
- <artifactId>cglib</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<version>10.2.2.0</version>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fg...@us...> - 2008-04-27 16:30:03
|
Revision: 778
http://openutils.svn.sourceforge.net/openutils/?rev=778&view=rev
Author: fgiust
Date: 2008-04-27 09:30:02 -0700 (Sun, 27 Apr 2008)
Log Message:
-----------
updated poms
Modified Paths:
--------------
trunk/openutils-testing/pom.xml
trunk/openutils-testing-junit/pom.xml
trunk/openutils-testing-testng/pom.xml
Modified: trunk/openutils-testing/pom.xml
===================================================================
--- trunk/openutils-testing/pom.xml 2008-04-27 14:24:19 UTC (rev 777)
+++ trunk/openutils-testing/pom.xml 2008-04-27 16:30:02 UTC (rev 778)
@@ -72,7 +72,6 @@
<groupId>org.dbunit</groupId>
<artifactId>dbunit</artifactId>
<version>2.2</version>
- <optional>true</optional>
<exclusions>
<exclusion>
<groupId>junit</groupId>
@@ -89,6 +88,17 @@
</exclusions>
</dependency>
<dependency>
+ <groupId>poi</groupId>
+ <artifactId>poi</artifactId>
+ <version>3.0.2-FINAL</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<classifier>jdk15</classifier>
Modified: trunk/openutils-testing-junit/pom.xml
===================================================================
--- trunk/openutils-testing-junit/pom.xml 2008-04-27 14:24:19 UTC (rev 777)
+++ trunk/openutils-testing-junit/pom.xml 2008-04-27 16:30:02 UTC (rev 778)
@@ -15,7 +15,7 @@
<dependency>
<groupId>net.sourceforge.openutils</groupId>
<artifactId>openutils-testing</artifactId>
- <version>2.1</version>
+ <version>2.1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>junit</groupId>
Modified: trunk/openutils-testing-testng/pom.xml
===================================================================
--- trunk/openutils-testing-testng/pom.xml 2008-04-27 14:24:19 UTC (rev 777)
+++ trunk/openutils-testing-testng/pom.xml 2008-04-27 16:30:02 UTC (rev 778)
@@ -15,7 +15,7 @@
<dependency>
<groupId>net.sourceforge.openutils</groupId>
<artifactId>openutils-testing</artifactId>
- <version>2.1</version>
+ <version>2.1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|