use of org.apache.cxf.ext.logging.event.LogEvent in project cxf by apache.
the class SOAPLoggingTest method testSoap.
@Test
public void testSoap() {
DefaultLogEventMapper mapper = new DefaultLogEventMapper();
Message message = new MessageImpl();
ExchangeImpl exchange = new ExchangeImpl();
ServiceInfo service = new ServiceInfo();
BindingInfo info = new BindingInfo(service, "bindingId");
SoapBinding value = new SoapBinding(info);
exchange.put(Binding.class, value);
OperationInfo opInfo = new OperationInfo();
opInfo.setName(new QName("http://my", "Operation"));
BindingOperationInfo boi = new BindingOperationInfo(info, opInfo);
exchange.put(BindingOperationInfo.class, boi);
message.setExchange(exchange);
LogEvent event = mapper.map(message);
Assert.assertEquals("{http://my}Operation", event.getOperationName());
}
use of org.apache.cxf.ext.logging.event.LogEvent in project cxf by apache.
the class RESTLoggingTest method testBinary.
@Test
public void testBinary() throws IOException, InterruptedException {
LoggingFeature loggingFeature = new LoggingFeature();
TestEventSender sender = new TestEventSender();
loggingFeature.setSender(sender);
Server server = createService(SERVICE_URI_BINARY, new TestServiceRestBinary(), loggingFeature);
server.start();
WebClient client = createClient(SERVICE_URI_BINARY, loggingFeature);
client.get(InputStream.class).close();
loggingFeature.setLogBinary(true);
client.get(InputStream.class).close();
client.close();
List<LogEvent> events = sender.getEvents();
await().until(() -> events.size(), is(8));
server.stop();
server.destroy();
// First call with binary logging false
assertContentLogged(events.get(0));
assertContentLogged(events.get(1));
assertContentNotLogged(events.get(2));
assertContentNotLogged(events.get(3));
// Second call with binary logging true
assertContentLogged(events.get(4));
assertContentLogged(events.get(5));
assertContentLogged(events.get(6));
assertContentLogged(events.get(7));
}
use of org.apache.cxf.ext.logging.event.LogEvent in project cxf by apache.
the class RESTLoggingTest method testEvents.
@Test
public void testEvents() throws MalformedURLException {
LoggingFeature loggingFeature = new LoggingFeature();
loggingFeature.setLogBinary(true);
TestEventSender sender = new TestEventSender();
loggingFeature.setSender(sender);
Server server = createService(SERVICE_URI, new TestServiceRest(), loggingFeature);
server.start();
WebClient client = createClient(SERVICE_URI, loggingFeature);
String result = client.get(String.class);
Assert.assertEquals("test1", result);
server.destroy();
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));
}
use of org.apache.cxf.ext.logging.event.LogEvent in project cxf by apache.
the class LoggingInInterceptor method handleMessage.
public void handleMessage(Message message) throws Fault {
if (isLoggingDisabledNow(message)) {
return;
}
createExchangeId(message);
final LogEvent event = new DefaultLogEventMapper().map(message);
if (shouldLogContent(event)) {
addContent(message, event);
} else {
event.setPayload(AbstractLoggingInterceptor.CONTENT_SUPPRESSED);
}
sender.send(event);
}
use of org.apache.cxf.ext.logging.event.LogEvent in project cxf by apache.
the class DefaultLogEventMapperTest method testNullValues.
/**
* Test for NPE described in CXF-6436
*/
@Test
public void testNullValues() {
DefaultLogEventMapper mapper = new DefaultLogEventMapper();
Message message = new MessageImpl();
message.put(Message.HTTP_REQUEST_METHOD, null);
message.put(Message.REQUEST_URI, null);
Exchange exchange = new ExchangeImpl();
message.setExchange(exchange);
LogEvent event = mapper.map(message);
Assert.assertEquals("", event.getOperationName());
}
Aggregations