Search in sources :

Example 16 with LoggingFeature

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

the class JAXRS20HttpsBookTest method testGetBook.

@Test
public void testGetBook() throws Exception {
    ClientBuilder builder = ClientBuilder.newBuilder();
    try (InputStream keystore = ClassLoaderUtils.getResourceAsStream("keys/Truststore.jks", this.getClass())) {
        KeyStore trustStore = loadStore(keystore, "password");
        builder.trustStore(trustStore);
    }
    builder.hostnameVerifier(new AllowAllHostnameVerifier());
    try (InputStream keystore = ClassLoaderUtils.getResourceAsStream("keys/Morpit.jks", this.getClass())) {
        KeyStore keyStore = loadStore(keystore, "password");
        builder.keyStore(keyStore, "password");
    }
    Client client = builder.build();
    client.register(new LoggingFeature());
    WebTarget target = client.target("https://localhost:" + PORT + "/bookstore/securebooks/123");
    Book b = target.request().accept(MediaType.APPLICATION_XML_TYPE).get(Book.class);
    assertEquals(123, b.getId());
}
Also used : InputStream(java.io.InputStream) Book(org.apache.cxf.systest.jaxrs.Book) LoggingFeature(org.apache.cxf.ext.logging.LoggingFeature) WebTarget(javax.ws.rs.client.WebTarget) Client(javax.ws.rs.client.Client) KeyStore(java.security.KeyStore) ClientBuilder(javax.ws.rs.client.ClientBuilder) Test(org.junit.Test)

Example 17 with LoggingFeature

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

the class ValidationClientServerTest method createService.

private SchemaValidation createService(Object validationConfig, String postfix) throws Exception {
    URL wsdl = getClass().getResource("/wsdl/schema_validation.wsdl");
    assertNotNull(wsdl);
    SchemaValidationService service = new SchemaValidationService(wsdl, serviceName);
    assertNotNull(service);
    SchemaValidation validation = service.getPort(portName, SchemaValidation.class);
    setAddress(validation, "http://localhost:" + PORT + "/SoapContext/" + postfix);
    ((BindingProvider) validation).getRequestContext().put(Message.SCHEMA_VALIDATION_ENABLED, validationConfig);
    ((BindingProvider) validation).getResponseContext().put(Message.SCHEMA_VALIDATION_ENABLED, validationConfig);
    new LoggingFeature().initialize((Client) validation, getBus());
    return validation;
}
Also used : LoggingFeature(org.apache.cxf.ext.logging.LoggingFeature) SchemaValidationService(org.apache.schema_validation.SchemaValidationService) URL(java.net.URL) SchemaValidation(org.apache.schema_validation.SchemaValidation)

Example 18 with LoggingFeature

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

the class SOAPLoggingTest method testEvents.

@Test
public void testEvents() throws MalformedURLException {
    TestService serviceImpl = new TestServiceImplementation();
    LoggingFeature loggingFeature = new LoggingFeature();
    TestEventSender sender = new TestEventSender();
    loggingFeature.setSender(sender);
    Endpoint ep = Endpoint.publish(SERVICE_URI, serviceImpl, loggingFeature);
    TestService client = createTestClient(loggingFeature);
    client.echo("test");
    ep.stop();
    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));
}
Also used : Endpoint(javax.xml.ws.Endpoint) LogEvent(org.apache.cxf.ext.logging.event.LogEvent) LoggingFeature(org.apache.cxf.ext.logging.LoggingFeature) Test(org.junit.Test) AbstractJaxWsTest(org.apache.cxf.jaxws.AbstractJaxWsTest)

Example 19 with LoggingFeature

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

the class MEXTest method setUpBeforeClass.

/**
 * @throws java.lang.Exception
 */
@BeforeClass
public static void setUpBeforeClass() throws Exception {
    JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
    factory.setServiceBean(new EchoImpl());
    factory.setAddress("local://Echo");
    factory.setTransportId(LocalTransportFactory.TRANSPORT_ID);
    server = factory.create();
    factory = new JaxWsServerFactoryBean();
    factory.setServiceBean(new MEXEndpoint(server));
    factory.setAddress("local://Echo-mex");
    factory.setTransportId(LocalTransportFactory.TRANSPORT_ID);
    factory.getFeatures().add(new LoggingFeature());
    mexServer = factory.create();
}
Also used : LoggingFeature(org.apache.cxf.ext.logging.LoggingFeature) JaxWsServerFactoryBean(org.apache.cxf.jaxws.JaxWsServerFactoryBean) BeforeClass(org.junit.BeforeClass)

Example 20 with LoggingFeature

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

the class MEXTest method testGet.

@Test
public void testGet() {
    // Create the client
    JaxWsProxyFactoryBean proxyFac = new JaxWsProxyFactoryBean();
    proxyFac.setBus(getStaticBus());
    proxyFac.setAddress("http://localhost:" + PORT + "/jaxws/addmex");
    proxyFac.getFeatures().add(new LoggingFeature());
    MetadataExchange exc = proxyFac.create(MetadataExchange.class);
    Metadata metadata = exc.get2004();
    assertNotNull(metadata);
    assertEquals(2, metadata.getMetadataSection().size());
    assertEquals("http://schemas.xmlsoap.org/wsdl/", metadata.getMetadataSection().get(0).getDialect());
    assertEquals("http://apache.org/cxf/systest/ws/addr_feature/", metadata.getMetadataSection().get(0).getIdentifier());
    assertEquals("http://www.w3.org/2001/XMLSchema", metadata.getMetadataSection().get(1).getDialect());
    GetMetadata body = new GetMetadata();
    body.setDialect("http://www.w3.org/2001/XMLSchema");
    metadata = exc.getMetadata(body);
    assertEquals(1, metadata.getMetadataSection().size());
    assertEquals("http://www.w3.org/2001/XMLSchema", metadata.getMetadataSection().get(0).getDialect());
}
Also used : GetMetadata(org.apache.cxf.ws.mex.model._2004_09.GetMetadata) LoggingFeature(org.apache.cxf.ext.logging.LoggingFeature) JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) Metadata(org.apache.cxf.ws.mex.model._2004_09.Metadata) GetMetadata(org.apache.cxf.ws.mex.model._2004_09.GetMetadata) MetadataExchange(org.apache.cxf.ws.mex.MetadataExchange) 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