Search in sources :

Example 6 with DefaultLogEventMapper

use of org.apache.cxf.ext.logging.event.DefaultLogEventMapper 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, Collections.emptySet());
    assertEquals("", event.getOperationName());
}
Also used : Exchange(org.apache.cxf.message.Exchange) Message(org.apache.cxf.message.Message) LogEvent(org.apache.cxf.ext.logging.event.LogEvent) DefaultLogEventMapper(org.apache.cxf.ext.logging.event.DefaultLogEventMapper) MessageImpl(org.apache.cxf.message.MessageImpl) ExchangeImpl(org.apache.cxf.message.ExchangeImpl) Test(org.junit.Test)

Example 7 with DefaultLogEventMapper

use of org.apache.cxf.ext.logging.event.DefaultLogEventMapper in project cxf by apache.

the class DefaultLogEventMapperTest method testPreflightRequestEventType.

@Test
public void testPreflightRequestEventType() {
    DefaultLogEventMapper mapper = new DefaultLogEventMapper();
    Message message = new MessageImpl();
    message.put(Message.HTTP_REQUEST_METHOD, "OPTIONS");
    message.put(Message.REQUEST_URI, "test");
    message.put(Message.RESPONSE_CODE, 200);
    Exchange exchange = new ExchangeImpl();
    // operation name not included
    exchange.put("org.apache.cxf.rs.security.cors.CrossOriginResourceSharingFilter", "preflight_passed");
    message.setExchange(exchange);
    exchange.setOutMessage(message);
    LogEvent event = mapper.map(message, Collections.emptySet());
    assertEquals(EventType.RESP_OUT, event.getType());
}
Also used : Exchange(org.apache.cxf.message.Exchange) Message(org.apache.cxf.message.Message) LogEvent(org.apache.cxf.ext.logging.event.LogEvent) DefaultLogEventMapper(org.apache.cxf.ext.logging.event.DefaultLogEventMapper) MessageImpl(org.apache.cxf.message.MessageImpl) ExchangeImpl(org.apache.cxf.message.ExchangeImpl) Test(org.junit.Test)

Example 8 with DefaultLogEventMapper

use of org.apache.cxf.ext.logging.event.DefaultLogEventMapper in project cxf by apache.

the class DefaultLogEventMapperTest method testMap.

@Test
public void testMap() {
    DefaultLogEventMapper mapper = new DefaultLogEventMapper();
    Message message = new MessageImpl();
    message.put(Message.HTTP_REQUEST_METHOD, "PUT");
    message.put(Message.REQUEST_URI, "test");
    Exchange exchange = new ExchangeImpl();
    message.setExchange(exchange);
    LogEvent event = mapper.map(message);
    assertEquals("PUT[test]", event.getOperationName());
}
Also used : Exchange(org.apache.cxf.message.Exchange) Message(org.apache.cxf.message.Message) LogEvent(org.apache.cxf.ext.logging.event.LogEvent) DefaultLogEventMapper(org.apache.cxf.ext.logging.event.DefaultLogEventMapper) MessageImpl(org.apache.cxf.message.MessageImpl) ExchangeImpl(org.apache.cxf.message.ExchangeImpl) Test(org.junit.Test)

Aggregations

DefaultLogEventMapper (org.apache.cxf.ext.logging.event.DefaultLogEventMapper)8 LogEvent (org.apache.cxf.ext.logging.event.LogEvent)8 ExchangeImpl (org.apache.cxf.message.ExchangeImpl)8 Message (org.apache.cxf.message.Message)8 MessageImpl (org.apache.cxf.message.MessageImpl)8 Test (org.junit.Test)8 Exchange (org.apache.cxf.message.Exchange)7 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 QName (javax.xml.namespace.QName)1 SoapBinding (org.apache.cxf.binding.soap.SoapBinding)1 AbstractJaxWsTest (org.apache.cxf.jaxws.AbstractJaxWsTest)1 BindingInfo (org.apache.cxf.service.model.BindingInfo)1 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)1 OperationInfo (org.apache.cxf.service.model.OperationInfo)1 ServiceInfo (org.apache.cxf.service.model.ServiceInfo)1