Tôi có ứng dụng dropwizard (0.7.0) mà tôi muốn chạy thử nghiệm tích hợp.Chạy di chuyển theo chương trình trong Dropwizard
tôi đã thiết lập một thử nghiệm tích hợp sử dụng DropwizardAppRule, như thế này:
@ClassRule
public static final DropwizardAppRule<MyAppConfiguration> RULE =
new DropwizardAppRule<MyAppConfiguration>(
MyApplication.class, Resources.getResource("testconfiguration.yml").getPath());
Khi tôi cố gắng để chạy thử nghiệm dưới đây sử dụng nó, nó không hoạt động bởi vì tôi đã không chạy di cư của tôi. Cách tốt nhất để chạy di chuyển là gì?
Test:
@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"));
}
Cấu hình:
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;
}
}