use of org.apache.cxf.ext.logging.event.LogEvent in project cxf by apache.
the class TruncatedTest method truncatedInboundInterceptorInputStream.
@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void truncatedInboundInterceptorInputStream() throws IOException {
Message message = new MessageImpl();
ByteArrayInputStream inputStream = new ByteArrayInputStream("TestMessage".getBytes(StandardCharsets.UTF_8));
message.setContent(InputStream.class, inputStream);
Exchange exchange = new ExchangeImpl();
message.setExchange(exchange);
LogEventSenderMock logEventSender = new LogEventSenderMock();
LoggingInInterceptor interceptor = new LoggingInInterceptor(logEventSender);
// set limit to 1 byte in order to get a truncated message!
interceptor.setLimit(1);
Collection<PhaseInterceptor<? extends Message>> interceptors = interceptor.getAdditionalInterceptors();
for (PhaseInterceptor intercept : interceptors) {
intercept.handleMessage(message);
}
interceptor.handleMessage(message);
LogEvent event = logEventSender.getLogEvent();
assertNotNull(event);
// only the first byte is read!
assertEquals("T", event.getPayload());
assertTrue(event.isTruncated());
}
use of org.apache.cxf.ext.logging.event.LogEvent in project cxf by apache.
the class SOAPLoggingTest method testEvents.
@Test
public void testEvents() throws MalformedURLException {
TestService serviceImpl = new TestServiceImplementation();
LoggingFeature loggingFeature = new LoggingFeature();
TestEventSender sender = new TestEventSender();
loggingFeature.setSender(sender);
Endpoint ep = Endpoint.publish(SERVICE_URI, serviceImpl, loggingFeature);
TestService client = createTestClient(loggingFeature);
client.echo("test");
ep.stop();
List<LogEvent> events = sender.getEvents();
Assert.assertEquals(4, events.size());
checkRequestOut(events.get(0));
checkRequestIn(events.get(1));
checkResponseOut(events.get(2));
checkResponseIn(events.get(3));
}
Aggregations