use of org.jboss.wsf.stack.cxf.client.UseThreadBusFeature in project jbossws-cxf by jbossws.
the class ClientServerLifeCycleTestCase method testCustomClientLifeCycleListener.
@Test
@RunAsClient
public void testCustomClientLifeCycleListener() throws Exception {
Bus bus = BusFactory.newInstance().createBus();
BusFactory.setThreadDefaultBus(bus);
try {
URL wsdlOneURL = new URL(baseURL + "/ServiceOne/EndpointOne?wsdl");
QName serviceOneName = new QName("http://org.jboss.ws.jaxws.cxf/jbws3098", "ServiceOne");
Service serviceOne = Service.create(wsdlOneURL, serviceOneName, new UseThreadBusFeature());
CustomClientLifeCycleListener listener = new CustomClientLifeCycleListener();
ClientLifeCycleManager mgr = bus.getExtension(ClientLifeCycleManager.class);
try {
mgr.registerListener(listener);
assertEquals(0, listener.getCount());
EndpointOne portOne = (EndpointOne) serviceOne.getPort(EndpointOne.class);
assertEquals(1, listener.getCount());
assertEquals("Foo", portOne.echo("Foo"));
} finally {
mgr.unRegisterListener(listener);
}
} finally {
bus.shutdown(true);
}
}
use of org.jboss.wsf.stack.cxf.client.UseThreadBusFeature in project jbossws-cxf by jbossws.
the class HelloDigestTestCase method testDigestAuthFail.
@Test
@RunAsClient
public void testDigestAuthFail() throws Exception {
final Bus bus = BusFactory.newInstance().createBus();
BusFactory.setThreadDefaultBus(bus);
try {
QName serviceName = new QName("http://jboss.org/http/security", "HelloService");
URL wsdlURL = getResourceURL("jaxws/cxf/httpauth/WEB-INF/wsdl/hello.wsdl");
Service service = Service.create(wsdlURL, serviceName, new UseThreadBusFeature());
Hello proxy = (Hello) service.getPort(Hello.class);
((BindingProvider) proxy).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, baseURL.toString());
((BindingProvider) proxy).getRequestContext().put(BindingProvider.USERNAME_PROPERTY, "jbossws");
((BindingProvider) proxy).getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, "wrongPwd");
HTTPConduit cond = (HTTPConduit) ClientProxy.getClient(proxy).getConduit();
cond.setAuthSupplier(new DigestAuthSupplier());
try {
proxy.helloRequest("number");
fail("Authorization exception expected!");
} catch (Exception e) {
assertTrue(e.getCause().getMessage().contains("Authorization"));
}
} finally {
bus.shutdown(true);
}
}
use of org.jboss.wsf.stack.cxf.client.UseThreadBusFeature in project jbossws-cxf by jbossws.
the class PolicyAttachmentTestCase method testEndpointWithCustomWSSEAndWSA.
@Test
@RunAsClient
@WrapThreadContextClassLoader
public void testEndpointWithCustomWSSEAndWSA() throws Exception {
Bus bus = BusFactory.newInstance().createBus();
BusFactory.setThreadDefaultBus(bus);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
PrintWriter pw = new PrintWriter(bos);
try {
bus.getInInterceptors().add(new LoggingInInterceptor(pw));
URL wsdlURL = new URL(baseURL + "/ServiceFour?wsdl");
QName serviceName = new QName("http://org.jboss.ws.jaxws.cxf/jbws3648", "ServiceFour");
Service service = Service.create(wsdlURL, serviceName, new UseThreadBusFeature());
EndpointFour proxy = (EndpointFour) service.getPort(EndpointFour.class);
setupWsse((BindingProvider) proxy);
try {
assertEquals("Foo4", proxy.echo("Foo4"));
} catch (Exception e) {
throw CryptoCheckHelper.checkAndWrapException(e);
}
final String m = bos.toString();
assertTrue("WS-Addressing was not enabled!", m.contains("http://www.w3.org/2005/08/addressing") && m.contains("http://www.w3.org/2005/08/addressing/anonymous"));
assertTrue("WS-Security was not enabled!", m.contains("http://www.w3.org/2001/04/xmlenc#rsa-1_5") && m.contains("http://www.w3.org/2001/04/xmlenc#aes256-cbc"));
} finally {
bus.shutdown(true);
pw.close();
bos.close();
}
}
use of org.jboss.wsf.stack.cxf.client.UseThreadBusFeature in project jbossws-cxf by jbossws.
the class PolicyAttachmentTestCase method testEndpointWithWSSEAndWSA.
@Test
@RunAsClient
@WrapThreadContextClassLoader
public void testEndpointWithWSSEAndWSA() throws Exception {
Bus bus = BusFactory.newInstance().createBus();
BusFactory.setThreadDefaultBus(bus);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
PrintWriter pw = new PrintWriter(bos);
try {
bus.getInInterceptors().add(new LoggingInInterceptor(pw));
URL wsdlURL = new URL(baseURL + "/ServiceThree?wsdl");
QName serviceName = new QName("http://org.jboss.ws.jaxws.cxf/jbws3648", "ServiceThree");
Service service = Service.create(wsdlURL, serviceName, new UseThreadBusFeature());
EndpointThree proxy = (EndpointThree) service.getPort(EndpointThree.class);
setupWsse((BindingProvider) proxy);
assertEquals("Foo3", proxy.echo("Foo3"));
final String m = bos.toString();
assertTrue("WS-Addressing was not enabled!", m.contains("http://www.w3.org/2005/08/addressing") && m.contains("http://www.w3.org/2005/08/addressing/anonymous"));
assertTrue("WS-Security was not enabled!", m.contains("http://www.w3.org/2001/04/xmlenc#rsa-1_5") && m.contains("http://www.w3.org/2001/04/xmlenc#tripledes-cbc"));
} finally {
bus.shutdown(true);
pw.close();
bos.close();
}
}
use of org.jboss.wsf.stack.cxf.client.UseThreadBusFeature in project jbossws-cxf by jbossws.
the class Helper method testEndpoint.
public boolean testEndpoint() throws Exception {
Bus bus = setBindingCustomizationOnClientSide();
try {
URL wsdlURL = new URL(endpointAddress + "?wsdl");
QName serviceName = new QName("http://org.jboss.ws/cxf/jaxbintros", "EndpointBeanService");
Service service = Service.create(wsdlURL, serviceName, new UseThreadBusFeature());
Endpoint port = service.getPort(Endpoint.class);
UserType user = new UserType();
QName qname = new QName("ns", "local", "prefix");
user.setQname(qname);
user.setString("Foo");
UserType result = port.echo(user);
if (!"Foo".equals(result.getString())) {
return false;
}
if (!qname.equals(result.getQname())) {
return false;
}
} finally {
bus.shutdown(true);
}
return true;
}
Aggregations