use of org.apache.cxf.phase.PhaseInterceptor 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.phase.PhaseInterceptor in project ddf by codice.
the class GuestInterceptorWrapper method handleMessage.
@Override
public void handleMessage(SoapMessage msg) throws Fault {
BundleContext context = getContext();
PhaseInterceptor guestIntercep = null;
Collection<ServiceReference<PhaseInterceptor>> guestIntercepRefs = null;
if (context != null) {
try {
guestIntercepRefs = context.getServiceReferences(PhaseInterceptor.class, "(interceptor=guest)");
} catch (InvalidSyntaxException e) {
// ignore, it isn't invalid
}
if (guestIntercepRefs != null && guestIntercepRefs.size() > 0) {
Iterator<ServiceReference<PhaseInterceptor>> iterator = guestIntercepRefs.iterator();
guestIntercep = context.getService(iterator.next());
}
if (guestIntercep != null) {
guestIntercep.handleMessage(msg);
} else {
LOGGER.debug("Guest Interceptor is not installed, ignoring");
}
} else {
LOGGER.debug("Unable to acquire bundle context for guest interceptor");
}
}
Aggregations