use of com.hotels.styx.api.extension.service.spi.Registry.ReloadResult in project styx by ExpediaGroup.
the class FileBackedRegistryTest method completesWithExceptionWhenErrorsDuringReload.
@Test
public void completesWithExceptionWhenErrorsDuringReload() throws Exception {
Resource configurationFile = mockResource("/styx/config", new ByteArrayInputStream(originalContent), new ByteArrayInputStream(newContent));
registry = new FileBackedRegistry<>(configurationFile, bytes -> {
if (new String(bytes).equals(new String(originalContent))) {
return List.of(backendService);
} else {
throw new JustATestException();
}
}, any -> true);
registry.addListener(listener);
ReloadResult outcome = await(registry.reload());
assertThat(outcome, is(reloaded("timestamp=NA, md5-hash=c346e70114eff08dceb13562f9abaa48, File reloaded.")));
verify(listener).onChange(eq(changeSet().added(backendService).build()));
outcome = await(registry.reload());
assertThat(outcome.outcome(), is(Registry.Outcome.FAILED));
assertThat(outcome.message(), is("timestamp=NA, md5-hash=24996b9d53b21a60c35dcb7ca3fb331a, Reload failure."));
assertThat(outcome.cause().get(), instanceOf(RuntimeException.class));
// Noting changed
verify(listener).onChange(eq(changeSet().added(backendService).build()));
}
Aggregations