Search in sources :

Example 6 with LoggingFeature

use of org.apache.cxf.ext.logging.LoggingFeature in project cxf by apache.

the class SimpleEventingIntegrationTest method setUpBeforeClass.

/**
 * Prepares the Event Source and Subscription Manager services
 */
@BeforeClass
public static void setUpBeforeClass() throws Exception {
    bus = BusFactory.getDefaultBus();
    // create and publish event source
    JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
    factory.setBus(bus);
    factory.setServiceBean(new TestingEventSource());
    factory.setAddress(URL_EVENT_SOURCE);
    factory.setTransportId(LocalTransportFactory.TRANSPORT_ID);
    eventSource = factory.create();
    // create and publish subscription manager
    factory = new JaxWsServerFactoryBean();
    factory.setBus(bus);
    factory.setServiceBean(new TestingSubscriptionManager());
    factory.setAddress(URL_SUBSCRIPTION_MANAGER);
    factory.setTransportId(LocalTransportFactory.TRANSPORT_ID);
    subscriptionManager = factory.create();
    new LoggingFeature().initialize(subscriptionManager, bus);
}
Also used : TestingSubscriptionManager(org.apache.cxf.ws.eventing.base.services.TestingSubscriptionManager) LoggingFeature(org.apache.cxf.ext.logging.LoggingFeature) JaxWsServerFactoryBean(org.apache.cxf.jaxws.JaxWsServerFactoryBean) TestingEventSource(org.apache.cxf.ws.eventing.base.services.TestingEventSource) BeforeClass(org.junit.BeforeClass)

Example 7 with LoggingFeature

use of org.apache.cxf.ext.logging.LoggingFeature in project cxf by apache.

the class JAXRSClientServerBookTest method testEchoForm.

@Test
public void testEchoForm() throws Exception {
    String address = "http://localhost:" + PORT + "/bookstore/form";
    WebClient wc = WebClient.create(address, Collections.singletonList(new LoggingFeature()));
    Form formOut = new Form().param("a", "aValue").param("b", "b value").param("c%", "cValue");
    Form formIn = wc.post(formOut, Form.class);
    assertEquals(3, formIn.asMap().size());
    assertEquals("aValue", formIn.asMap().getFirst("a"));
    assertEquals("b value", formIn.asMap().getFirst("b"));
    assertEquals("cValue", formIn.asMap().getFirst("c%"));
}
Also used : Form(javax.ws.rs.core.Form) LoggingFeature(org.apache.cxf.ext.logging.LoggingFeature) WebClient(org.apache.cxf.jaxrs.client.WebClient) Test(org.junit.Test)

Example 8 with LoggingFeature

use of org.apache.cxf.ext.logging.LoggingFeature in project cxf by apache.

the class SampleRestApplication method rsServer.

@Bean
public Server rsServer() {
    JAXRSServerFactoryBean endpoint = new JAXRSServerFactoryBean();
    endpoint.setBus(bus);
    endpoint.setServiceBeans(Arrays.<Object>asList(new HelloServiceImpl1(), new HelloServiceImpl2()));
    endpoint.setAddress("/");
    endpoint.setFeatures(Arrays.asList(createOpenApiFeature(), new LoggingFeature()));
    return endpoint.create();
}
Also used : HelloServiceImpl2(sample.rs.service.hello2.HelloServiceImpl2) HelloServiceImpl1(sample.rs.service.hello1.HelloServiceImpl1) LoggingFeature(org.apache.cxf.ext.logging.LoggingFeature) JAXRSServerFactoryBean(org.apache.cxf.jaxrs.JAXRSServerFactoryBean) JAXRSServerFactoryBean(org.apache.cxf.jaxrs.JAXRSServerFactoryBean) Bean(org.springframework.context.annotation.Bean)

Example 9 with LoggingFeature

use of org.apache.cxf.ext.logging.LoggingFeature in project cxf by apache.

the class RESTLoggingTest method testSlf4j.

@Test
public void testSlf4j() throws IOException {
    LoggingFeature loggingFeature = new LoggingFeature();
    Server server = createService(SERVICE_URI, new TestServiceRest(), loggingFeature);
    server.start();
    WebClient client = createClient(SERVICE_URI, loggingFeature);
    String result = client.get(String.class);
    server.destroy();
    Assert.assertEquals("test1", result);
}
Also used : Server(org.apache.cxf.endpoint.Server) LoggingFeature(org.apache.cxf.ext.logging.LoggingFeature) WebClient(org.apache.cxf.jaxrs.client.WebClient) Test(org.junit.Test)

Example 10 with LoggingFeature

use of org.apache.cxf.ext.logging.LoggingFeature 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));
}
Also used : Server(org.apache.cxf.endpoint.Server) LogEvent(org.apache.cxf.ext.logging.event.LogEvent) InputStream(java.io.InputStream) LoggingFeature(org.apache.cxf.ext.logging.LoggingFeature) WebClient(org.apache.cxf.jaxrs.client.WebClient) Test(org.junit.Test)

Aggregations

LoggingFeature (org.apache.cxf.ext.logging.LoggingFeature)21 Test (org.junit.Test)13 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)4 WebClient (org.apache.cxf.jaxrs.client.WebClient)4 URL (java.net.URL)3 Endpoint (javax.xml.ws.Endpoint)3 Client (org.apache.cxf.endpoint.Client)3 Server (org.apache.cxf.endpoint.Server)3 LogEvent (org.apache.cxf.ext.logging.event.LogEvent)3 BeforeClass (org.junit.BeforeClass)3 Closeable (java.io.Closeable)2 InputStream (java.io.InputStream)2 ArrayList (java.util.ArrayList)2 QName (javax.xml.namespace.QName)2 BindingProvider (javax.xml.ws.BindingProvider)2 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)2 AbstractJaxWsTest (org.apache.cxf.jaxws.AbstractJaxWsTest)2 JaxWsServerFactoryBean (org.apache.cxf.jaxws.JaxWsServerFactoryBean)2 AddNumberImpl (org.apache.cxf.systest.ws.addr_fromjava.client.AddNumberImpl)2 AddNumbersException_Exception (org.apache.cxf.systest.ws.addr_fromjava.client.AddNumbersException_Exception)2