Search in sources :

Example 1 with LoggingFeature

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

the class SoapUDPTest method startServers.

@BeforeClass
public static void startServers() throws Exception {
    staticBus = BusFactory.getDefaultBus();
    new LoggingFeature().initialize(staticBus);
    BusFactory.setThreadDefaultBus(staticBus);
    assertTrue("server did not launch correctly", launchServer(Server.class, true));
}
Also used : LoggingFeature(org.apache.cxf.ext.logging.LoggingFeature) BeforeClass(org.junit.BeforeClass)

Example 2 with LoggingFeature

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

the class WSAFromJavaTest method testNoRelatesToHeader.

@Test
public void testNoRelatesToHeader() throws Exception {
    new LoggingFeature().initialize(this.getBus());
    AddNumberImpl port = getPort();
    Client c = ClientProxy.getClient(port);
    c.getInInterceptors().add(new RemoveRelatesToHeaderInterceptor());
    long start = System.currentTimeMillis();
    port.addNumbers(1, 2);
    try {
        port.addNumbers3(-1, -1);
    } catch (Exception ex) {
    // ignore, expected
    }
    long end = System.currentTimeMillis();
    assertTrue((end - start) < 50000);
}
Also used : AddNumberImpl(org.apache.cxf.systest.ws.addr_fromjava.client.AddNumberImpl) LoggingFeature(org.apache.cxf.ext.logging.LoggingFeature) Client(org.apache.cxf.endpoint.Client) AddNumbersException_Exception(org.apache.cxf.systest.ws.addr_fromjava.client.AddNumbersException_Exception) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) Test(org.junit.Test)

Example 3 with LoggingFeature

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

the class WSAFromJavaTest method testFaultFromNonAddressService.

@Test
public void testFaultFromNonAddressService() throws Exception {
    new LoggingFeature().initialize(this.getBus());
    AddNumberImpl port = getPort();
    java.util.Map<String, Object> requestContext = ((BindingProvider) port).getRequestContext();
    requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + PORT + "/AddNumberImplPort-noaddr");
    long start = System.currentTimeMillis();
    port.addNumbers(1, 2);
    try {
        port.addNumbers3(-1, -1);
    } catch (Exception ex) {
    // ignore, expected
    }
    long end = System.currentTimeMillis();
    assertTrue((end - start) < 50000);
}
Also used : AddNumberImpl(org.apache.cxf.systest.ws.addr_fromjava.client.AddNumberImpl) LoggingFeature(org.apache.cxf.ext.logging.LoggingFeature) BindingProvider(javax.xml.ws.BindingProvider) AddNumbersException_Exception(org.apache.cxf.systest.ws.addr_fromjava.client.AddNumbersException_Exception) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) Test(org.junit.Test)

Example 4 with LoggingFeature

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

the class CodeFirstTest method testClient.

@Test
public void testClient() throws Exception {
    Hello serviceImpl = new Hello();
    try (EndpointImpl ep = new EndpointImpl(getBus(), serviceImpl, (String) null)) {
        ep.publish("local://localhost:9090/hello");
        QName serviceName = new QName("http://service.jaxws.cxf.apache.org/", "HelloService");
        QName portName = new QName("http://service.jaxws.cxf.apache.org/", "HelloPort");
        // need to set the same bus with service , so use the ServiceImpl
        ServiceImpl service = new ServiceImpl(getBus(), (URL) null, serviceName, null);
        service.addPort(portName, "http://schemas.xmlsoap.org/soap/", "local://localhost:9090/hello");
        HelloInterface proxy = service.getPort(portName, HelloInterface.class, new LoggingFeature());
        Client client = ClientProxy.getClient(proxy);
        boolean found = false;
        for (Interceptor<? extends Message> i : client.getOutInterceptors()) {
            if (i instanceof LoggingOutInterceptor) {
                found = true;
            }
        }
        assertTrue(found);
        assertEquals("Get the wrong result", "hello", proxy.sayHi("hello"));
        String[] strInput = new String[2];
        strInput[0] = "Hello";
        strInput[1] = "Bonjour";
        String[] strings = proxy.getStringArray(strInput);
        assertEquals(strings.length, 2);
        assertEquals(strings[0], "HelloHello");
        assertEquals(strings[1], "BonjourBonjour");
        List<String> listInput = new ArrayList<>();
        listInput.add("Hello");
        listInput.add("Bonjour");
        List<String> list = proxy.getStringList(listInput);
        assertEquals(list.size(), 2);
        assertEquals(list.get(0), "HelloHello");
        assertEquals(list.get(1), "BonjourBonjour");
        // now the client side can't unmarshal the complex type without binding types annoutation
        List<String> result = proxy.getGreetings();
        assertEquals(2, result.size());
    }
}
Also used : QName(javax.xml.namespace.QName) ArrayServiceImpl(org.apache.cxf.jaxws.service.ArrayServiceImpl) FooServiceImpl(org.apache.cxf.jaxws.service.FooServiceImpl) ArrayList(java.util.ArrayList) Hello(org.apache.cxf.jaxws.service.Hello) LoggingOutInterceptor(org.apache.cxf.ext.logging.LoggingOutInterceptor) LoggingFeature(org.apache.cxf.ext.logging.LoggingFeature) HelloInterface(org.apache.cxf.jaxws.service.HelloInterface) Client(org.apache.cxf.endpoint.Client) Test(org.junit.Test)

Example 5 with LoggingFeature

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

the class SOAPLoggingTest method testSlf4j.

@Test
public void testSlf4j() throws MalformedURLException {
    TestService serviceImpl = new TestServiceImplementation();
    LoggingFeature loggingFeature = new LoggingFeature();
    loggingFeature.setPrettyLogging(true);
    // Setting the limit should omit parts of the body but the result should still be well formed xml
    loggingFeature.setLimit(140);
    Endpoint ep = Endpoint.publish(SERVICE_URI, serviceImpl, loggingFeature);
    TestService client = createTestClient(loggingFeature);
    client.echo("test");
    ep.stop();
}
Also used : Endpoint(javax.xml.ws.Endpoint) LoggingFeature(org.apache.cxf.ext.logging.LoggingFeature) Test(org.junit.Test) AbstractJaxWsTest(org.apache.cxf.jaxws.AbstractJaxWsTest)

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