【发布时间】:2015-08-21 00:19:26
【问题描述】:
我有 dropwizard-application (0.7.0),我想为其运行集成测试。
我已经使用 DropwizardAppRule 设置了一个集成测试,如下所示:
@ClassRule
public static final DropwizardAppRule<MyAppConfiguration> RULE =
new DropwizardAppRule<MyAppConfiguration>(
MyApplication.class, Resources.getResource("testconfiguration.yml").getPath());
当我尝试使用它运行以下测试时,它不起作用,因为我还没有运行我的迁移。运行迁移的最佳方式是什么?
测试:
@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@email.com", "password"));
}
配置:
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;
}
}
【问题讨论】:
标签: java liquibase dropwizard