Created
May 22, 2012 11:20
-
-
Save awilmore/2768441 to your computer and use it in GitHub Desktop.
Loading SQL Resources Using Spring IO Resource Annotation
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
import org.junit.Before; | |
import org.junit.runner.RunWith; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.core.io.Resource; | |
import org.springframework.jdbc.core.JdbcTemplate; | |
import org.springframework.test.context.ContextConfiguration; | |
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; | |
@RunWith(SpringJUnit4ClassRunner.class) | |
@ContextConfiguration({ | |
"/spring/applicationContext.xml", | |
"/springtest/applicationContext-testDataSource.xml"}) | |
public class SpringJUnitIOResourceExampleTest { | |
@Autowired | |
private SomeDaoImpl someDaoImpl; | |
@Autowired | |
private Resource testDatabaseSetupScriptSmall; | |
@Autowired | |
private StatementLoader statementLoader; | |
@Autowired | |
private JdbcTemplate jdbcTemplate; | |
@Before | |
public void init() { | |
statementLoader.executeStatements(testDatabaseSetupScriptSmall, jdbcTemplate); | |
} | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment