How do I set an @Value
property for a context which I @Import
into my unit test?
For example:
@Configuration
public void DatabaseTestsConfiguration
{
@Value("${test.generateddl:true}")
private boolean generateDdl;
@Bean
public JpaVendorAdapter jpaVendorAdapter()
{
HibernateJpaVendorAdapter hibernateJpaVendorAdapter = new HibernateJpaVendorAdapter();
hibernateJpaVendorAdapter.setShowSql( false );
hibernateJpaVendorAdapter.setGenerateDdl( generateDdl );
hibernateJpaVendorAdapter.setDatabase( Database.H2 );
return hibernateJpaVendorAdapter;
}
// Some more @Bean's here
}
In my unit test:
@Test
@ContextConfiguration
public void SomeTest extends AbstractTransactionalTestNGSpringContextTests
{
@Configuration
@Import(DatabaseTestsConfiguration.class)
public static class TestConfiguration
{
}
}
How do I now override the property test.generateddl
to be false
in my unit test? Note that I want to have it only for this unit test, so specifying something on the command line is a no-go.
Aucun commentaire:
Enregistrer un commentaire