use of com.hotels.styx.support.JustATestException in project styx by ExpediaGroup.
the class EventualTest method createFromError.
@Test
public void createFromError() {
Eventual<String> eventual = Eventual.error(new JustATestException());
StepVerifier.create(eventual).expectError(RuntimeException.class).verify();
}
use of com.hotels.styx.support.JustATestException in project styx by ExpediaGroup.
the class FileBackedBackendServicesRegistryTest method serviceStarts_logsInfoWhenReloadFails.
@Test
public void serviceStarts_logsInfoWhenReloadFails() {
FileBackedRegistry<BackendService> delegate = mock(FileBackedRegistry.class);
when(delegate.fileName()).thenReturn("/monitored/origins.yml");
when(delegate.reload()).thenReturn(completedFuture(failed("md5-hash: 9034890345289043, Failed to load file", new JustATestException())));
registry = new FileBackedBackendServicesRegistry(delegate, FileMonitor.DISABLED);
try {
registry.startService().get();
} catch (Throwable any) {
// pass
} finally {
assertThat(log.lastMessage(), is(loggingEvent(ERROR, "Backend services reload failed. reason='Initial load', md5-hash: 9034890345289043, Failed to load file, file='/monitored/origins.yml'", JustATestException.class, JustATestException.DEFAULT_MESSAGE)));
}
}
use of com.hotels.styx.support.JustATestException 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()));
}
use of com.hotels.styx.support.JustATestException in project styx by ExpediaGroup.
the class HttpPipelineHandlerTest method anotherExceptionInSendingResponseState.
@Test
public void anotherExceptionInSendingResponseState() throws Exception {
// In Sending Response state,
// A non-IO exception bubbles up the Netty pipeline
setupHandlerTo(SENDING_RESPONSE);
handler.exceptionCaught(ctx, new JustATestException());
assertThat(responseUnsubscribed.get(), is(true));
verify(statsCollector).onTerminate(request.id());
assertThat(handler.state(), is(TERMINATED));
}
Aggregations