Last active
April 6, 2022 02:19
-
-
Save A-pZ/3cbff9c3b2eebb2617db3cb38dc43840 to your computer and use it in GitHub Desktop.
TestDatabaseConfig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.github.apz.sample.mapper; | |
import org.dbunit.dataset.IDataSet; | |
import org.dbunit.dataset.csv.CsvDataSet; | |
import org.springframework.core.io.Resource; | |
import com.github.springtestdbunit.dataset.AbstractDataSetLoader; | |
public class CSVDataSetLoader extends AbstractDataSetLoader { | |
@Override | |
protected IDataSet createDataSet(Resource resource) throws Exception { | |
return new CsvDataSet(resource.getFile()); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.github.apz.sample.mapper; | |
import javax.sql.DataSource; | |
import org.springframework.context.annotation.Bean; | |
import org.springframework.context.annotation.Configuration; | |
import com.github.springtestdbunit.bean.DatabaseDataSourceConnectionFactoryBean; | |
@Configuration | |
public class TestDatabaseConfig { | |
@Bean(name = "dbUnitDatabaseConnection") | |
public DatabaseDataSourceConnectionFactoryBean dbUnitDatabaseConnection(DataSource dataSource) { | |
DatabaseDataSourceConnectionFactoryBean connectionFactory = new DatabaseDataSourceConnectionFactoryBean(); | |
connectionFactory.setDataSource(dataSource); | |
return connectionFactory; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment