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());
}
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;
}
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));
}
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();
}
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());
}
Aggregations