통합 테스트를 실행하려는 dropwizard-application (0.7.0)이 있습니다.Dropwizard에서 프로그래밍 방식으로 마이그레이션 실행
나는이 같은 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 protected]", "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;
}
}