use of org.apache.cxf.ext.logging.LoggingOutInterceptor in project cxf by apache.
the class JaxWsDynamicClientTest method testArrayList.
@Test
public void testArrayList() throws Exception {
JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
Client client = dcf.createClient(new URL("http://localhost:" + PORT1 + "/ArrayService?wsdl"));
String[] values = new String[] { "foobar", "something" };
List<String> list = Arrays.asList(values);
client.getOutInterceptors().add(new LoggingOutInterceptor());
client.getInInterceptors().add(new LoggingInInterceptor());
client.invoke("init", list);
}
use of org.apache.cxf.ext.logging.LoggingOutInterceptor in project cxf by apache.
the class JAXRSKerberosBookTest method testGetBookWithInterceptor.
@Test
public void testGetBookWithInterceptor() throws Exception {
if (!runTests) {
return;
}
WebClient wc = WebClient.create("http://localhost:" + PORT + "/bookstore/books/123");
KerberosAuthOutInterceptor kbInterceptor = new KerberosAuthOutInterceptor();
AuthorizationPolicy policy = new AuthorizationPolicy();
policy.setAuthorizationType(HttpAuthHeader.AUTH_TYPE_NEGOTIATE);
policy.setAuthorization("alice");
policy.setUserName("alice");
policy.setPassword("alice");
kbInterceptor.setPolicy(policy);
kbInterceptor.setCredDelegation(true);
WebClient.getConfig(wc).getOutInterceptors().add(new LoggingOutInterceptor());
WebClient.getConfig(wc).getOutInterceptors().add(kbInterceptor);
// Required so as to get it working with our KDC
kbInterceptor.setServicePrincipalName("bob@service.ws.apache.org");
kbInterceptor.setServiceNameType(GSSName.NT_HOSTBASED_SERVICE);
Book b = wc.get(Book.class);
Assert.assertEquals(b.getId(), 123);
}
use of org.apache.cxf.ext.logging.LoggingOutInterceptor in project cxf by apache.
the class ClientServerSwaTest method testSwa.
@Test
public void testSwa() throws Exception {
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setWsdlLocation("classpath:/swa-mime_jms.wsdl");
factory.setTransportId(SoapJMSConstants.SOAP_JMS_SPECIFICIATION_TRANSPORTID);
factory.setServiceName(new QName("http://cxf.apache.org/swa", "SwAService"));
factory.setEndpointName(new QName("http://cxf.apache.org/swa", "SwAServiceJMSPort"));
factory.setAddress(ADDRESS + broker.getEncodedBrokerURL());
factory.getOutInterceptors().add(new LoggingOutInterceptor());
SwAService port = factory.create(SwAService.class);
Holder<String> textHolder = new Holder<String>();
Holder<DataHandler> data = new Holder<DataHandler>();
ByteArrayDataSource source = new ByteArrayDataSource("foobar".getBytes(), "application/octet-stream");
DataHandler handler = new DataHandler(source);
data.value = handler;
textHolder.value = "Hi";
port.echoData(textHolder, data);
InputStream bis = null;
bis = data.value.getDataSource().getInputStream();
byte[] b = new byte[10];
bis.read(b, 0, 10);
String string = IOUtils.newStringFromBytes(b);
assertEquals("testfoobar", string);
assertEquals("Hi", textHolder.value);
if (port instanceof Closeable) {
((Closeable) port).close();
}
}
use of org.apache.cxf.ext.logging.LoggingOutInterceptor in project cxf by apache.
the class CXF6655Test method testConnectionWithProxy.
@Test
public void testConnectionWithProxy() throws Exception {
QName serviceName = new QName("http://cxf.apache.org/systest/jaxws/", "HelloService");
HelloService service = new HelloService(null, serviceName);
assertNotNull(service);
Hello hello = service.getHelloPort();
Client client = ClientProxy.getClient(hello);
client.getInInterceptors().add(new LoggingInInterceptor());
client.getOutInterceptors().add(new LoggingOutInterceptor());
HTTPConduit http = (HTTPConduit) client.getConduit();
HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
httpClientPolicy.setAllowChunking(false);
httpClientPolicy.setReceiveTimeout(0);
httpClientPolicy.setProxyServerType(ProxyServerType.HTTP);
httpClientPolicy.setProxyServer("localhost");
httpClientPolicy.setProxyServerPort(PROXY_PORT);
http.setClient(httpClientPolicy);
((BindingProvider) hello).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + PORT + "/hello");
assertEquals("getSayHi", hello.sayHi("SayHi"));
}
use of org.apache.cxf.ext.logging.LoggingOutInterceptor in project cxf by apache.
the class DispatchClientServerWithMalformedResponseTest method setUp.
@org.junit.Before
public void setUp() {
BusFactory.setThreadDefaultBus(getStaticBus());
BusFactory.getThreadDefaultBus().getOutInterceptors().add(new LoggingOutInterceptor());
BusFactory.getThreadDefaultBus().getInInterceptors().add(new LoggingInInterceptor());
BusFactory.getThreadDefaultBus().getInInterceptors().add(new MalformedResponseInterceptor());
}
Aggregations