Ho un'applicazione dropwizard (0.7.0) per la quale voglio eseguire i test di integrazione.Eseguire le migrazioni al livello di programmazione in Dropwizard
Ho creato un test di integrazione utilizzando DropwizardAppRule, in questo modo:
@ClassRule
public static final DropwizardAppRule<MyAppConfiguration> RULE =
new DropwizardAppRule<MyAppConfiguration>(
MyApplication.class, Resources.getResource("testconfiguration.yml").getPath());
Quando provo ad eseguire i test di seguito utilizzando esso, non funziona perché non ho eseguito i miei migrazioni. Qual è il modo migliore per eseguire le migrazioni?
prova:
@Test
public void fooTest() {
Client client = new Client();
String root = String.format("http://localhost:%d/", RULE.getLocalPort());
URI uri = UriBuilder.fromUri(root).path("/users").build();
client.resource(uri).accept(MediaType.APPLICATION_JSON).type(MediaType.APPLICATION_JSON).post(User.class, new LoginUserDTO("[email protected]", "password"));
}
Configurazione:
public class MyAppConfiguration extends Configuration {
@Valid
@NotNull
private DataSourceFactory database = new DataSourceFactory();
@JsonProperty("database")
public DataSourceFactory getDataSourceFactory() {
return database;
}
@JsonProperty("database")
public void setDataSourceFactory(DataSourceFactory dataSourceFactory) {
this.database = dataSourceFactory;
}
}