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. |