use of com.hotels.styx.support.matchers.LoggingTestSupport in project styx by ExpediaGroup.
the class GraphiteReporterServiceTest method setUp.
@BeforeEach
public void setUp() {
meterRegistry = new CompositeMeterRegistry();
log = new LoggingTestSupport(GraphiteReporterService.class);
}
use of com.hotels.styx.support.matchers.LoggingTestSupport in project styx by ExpediaGroup.
the class FsmEventProcessorTest method setUp.
@BeforeEach
public void setUp() {
stateMachine = new StateMachine.Builder<String>().initialState("start").transition("start", TestEventOk.class, event -> "end").transition("start", TestEventError.class, event -> {
throw new RuntimeException("Test exception message");
}).onInappropriateEvent((x, y) -> "error").build();
errorHandler = mock(BiConsumer.class);
logger = new LoggingTestSupport(FsmEventProcessor.class);
}
use of com.hotels.styx.support.matchers.LoggingTestSupport in project styx by ExpediaGroup.
the class HttpPipelineHandlerTest method setUp.
@BeforeEach
public void setUp() throws Exception {
logger = new LoggingTestSupport(HttpPipelineHandler.class);
statsCollector = mock(RequestStatsCollector.class);
errorListener = mock(HttpErrorStatusListener.class);
ctx = mockCtx();
responseObservable = EmitterProcessor.create();
responseUnsubscribed = new AtomicBoolean(false);
writerFuture = new CompletableFuture<>();
responseWriter = mock(HttpResponseWriter.class);
when(responseWriter.write(nullable(LiveHttpResponse.class))).thenReturn(writerFuture);
responseWriterFactory = mock(HttpResponseWriterFactory.class);
when(responseWriterFactory.create(nullable(ChannelHandlerContext.class))).thenReturn(responseWriter);
pipeline = mock(HttpHandler.class);
when(pipeline.handle(nullable(LiveHttpRequest.class), nullable(HttpInterceptor.Context.class))).thenReturn(new Eventual<>(Flux.from(responseObservable.doOnCancel(() -> responseUnsubscribed.set(true)))));
request = get("/foo").id("REQUEST-1-ID").build();
response = response().build();
responseEnhancer = mock(ResponseEnhancer.class);
when(responseEnhancer.enhance(nullable(LiveHttpResponse.Transformer.class), nullable(LiveHttpRequest.class))).thenAnswer(invocationOnMock -> invocationOnMock.getArguments()[0]);
when(responseEnhancer.enhance(nullable(LiveHttpResponse.class), nullable(LiveHttpRequest.class))).thenAnswer(invocationOnMock -> invocationOnMock.getArguments()[0]);
setupHandlerTo(ACCEPTING_REQUESTS);
}
use of com.hotels.styx.support.matchers.LoggingTestSupport in project styx by ExpediaGroup.
the class HttpResponseWriterTest method setUp.
@BeforeEach
public void setUp() {
LOGGER = new LoggingTestSupport(HttpResponseWriter.class);
contentObservable = EmitterProcessor.create();
channelArgs = new ArrayDeque<>();
channelRead = new AtomicBoolean(false);
}
use of com.hotels.styx.support.matchers.LoggingTestSupport in project styx by ExpediaGroup.
the class PluginLoadingForStartupTest method attemptsToLoadAllPluginsEvenIfSomePluginFactoriesCannotBeLoaded.
@Test
public void attemptsToLoadAllPluginsEvenIfSomePluginFactoriesCannotBeLoaded() {
LoggingTestSupport log = new LoggingTestSupport(FailureHandling.class);
String yaml = "" + "plugins:\n" + " active: myPlugin1,myPlugin2,myPlugin3\n" + " all:\n" + " myPlugin1:\n" + " factory:\n" + " class: BadClassName\n" + " classPath: " + FIXTURES_CLASS_PATH + "\n" + " myPlugin2:\n" + " factory:\n" + " class: BadClassName\n" + " classPath: " + FIXTURES_CLASS_PATH + "\n" + " myPlugin3:\n" + " factory:\n" + " class: BadClassName\n" + " classPath: " + FIXTURES_CLASS_PATH + "\n";
Exception e = assertThrows(RuntimeException.class, () -> PluginLoadingForStartup.loadPlugins(environment(yaml)));
assertThat(e.getMessage(), matchesPattern("3 plugin\\(s\\) could not be loaded: failedPlugins=\\[myPlugin1, myPlugin2, myPlugin3\\]; failureCauses=\\[" + "myPlugin1: com.hotels.styx.api.configuration.ConfigurationException: Could not load a plugin factory.*, " + "myPlugin2: com.hotels.styx.api.configuration.ConfigurationException: Could not load a plugin factory.*, " + "myPlugin3: com.hotels.styx.api.configuration.ConfigurationException: Could not load a plugin factory.*\\]"));
assertThat(log.log(), hasItem(loggingEvent(ERROR, "Could not load plugin: pluginName=myPlugin1; factoryClass=.*", ConfigurationException.class, "Could not load a plugin factory for.*")));
log.stop();
}
Aggregations