Search in sources :

Example 1 with DefaultLogEventMapper

use of org.apache.cxf.ext.logging.event.DefaultLogEventMapper 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, Collections.emptySet());
    Assert.assertEquals("{http://my}Operation", event.getOperationName());
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) OperationInfo(org.apache.cxf.service.model.OperationInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) Message(org.apache.cxf.message.Message) LogEvent(org.apache.cxf.ext.logging.event.LogEvent) QName(javax.xml.namespace.QName) BindingInfo(org.apache.cxf.service.model.BindingInfo) DefaultLogEventMapper(org.apache.cxf.ext.logging.event.DefaultLogEventMapper) MessageImpl(org.apache.cxf.message.MessageImpl) ExchangeImpl(org.apache.cxf.message.ExchangeImpl) SoapBinding(org.apache.cxf.binding.soap.SoapBinding) Test(org.junit.Test) AbstractJaxWsTest(org.apache.cxf.jaxws.AbstractJaxWsTest)

Example 2 with DefaultLogEventMapper

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

the class DefaultLogEventMapperTest method testUriValue.

/**
 * Test for address concatenation in CXF-8127
 */
@Test
public void testUriValue() {
    DefaultLogEventMapper mapper = new DefaultLogEventMapper();
    Message message = new MessageImpl();
    message.put(Message.ENDPOINT_ADDRESS, "http://localhost:9001/");
    message.put(Message.REQUEST_URI, "/api");
    Exchange exchange = new ExchangeImpl();
    message.setExchange(exchange);
    LogEvent event = mapper.map(message, Collections.emptySet());
    assertEquals("http://localhost:9001/api", event.getAddress());
}
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 3 with DefaultLogEventMapper

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

the class DefaultLogEventMapperTest method testRest.

@Test
public void testRest() {
    DefaultLogEventMapper mapper = new DefaultLogEventMapper();
    Message message = new MessageImpl();
    message.put(Message.HTTP_REQUEST_METHOD, "GET");
    message.put(Message.REQUEST_URI, "test");
    Exchange exchange = new ExchangeImpl();
    message.setExchange(exchange);
    LogEvent event = mapper.map(message, Collections.emptySet());
    assertEquals("GET[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)

Example 4 with DefaultLogEventMapper

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

the class DefaultLogEventMapperTest method shouldMaskHeaders.

@Test
public void shouldMaskHeaders() {
    final DefaultLogEventMapper mapper = new DefaultLogEventMapper();
    final Message message = new MessageImpl();
    message.put(Message.ENDPOINT_ADDRESS, "http://localhost:9001/");
    message.put(Message.REQUEST_URI, "/api");
    Exchange exchange = new ExchangeImpl();
    message.setExchange(exchange);
    final Map<String, Object> headers = new HashMap<>();
    headers.put(TEST_HEADER_NAME, Arrays.asList(TEST_HEADER_VALUE));
    final Set<String> sensitiveHeaders = new HashSet<>();
    sensitiveHeaders.add(TEST_HEADER_NAME);
    message.put(Message.PROTOCOL_HEADERS, headers);
    LogEvent event = mapper.map(message, sensitiveHeaders);
    assertEquals(MASKED_HEADER_VALUE, event.getHeaders().get(TEST_HEADER_NAME));
}
Also used : Exchange(org.apache.cxf.message.Exchange) Message(org.apache.cxf.message.Message) HashMap(java.util.HashMap) 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) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 5 with DefaultLogEventMapper

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

the class DefaultLogEventMapperTest method testMapNullSensitiveProtocolHeaders.

@Test
public void testMapNullSensitiveProtocolHeaders() {
    DefaultLogEventMapper mapper = new DefaultLogEventMapper();
    Message message = new MessageImpl();
    message.put(Message.HTTP_REQUEST_METHOD, "POST");
    message.put(Message.REQUEST_URI, "nullTest");
    Exchange exchange = new ExchangeImpl();
    message.setExchange(exchange);
    LogEvent event = mapper.map(message, null);
    assertEquals("POST[nullTest]", 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