Skip to content

Instantly share code, notes, and snippets.

@awilmore
Created May 22, 2012 11:20
Show Gist options
  • Save awilmore/2768441 to your computer and use it in GitHub Desktop.
Save awilmore/2768441 to your computer and use it in GitHub Desktop.
Loading SQL Resources Using Spring IO Resource Annotation
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