Search in sources :

Example 16 with UseThreadBusFeature

use of org.jboss.wsf.stack.cxf.client.UseThreadBusFeature in project jbossws-cxf by jbossws.

the class HelloDigestTestCase method testDigest.

@Test
@RunAsClient
public void testDigest() 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, "jbossws");
        HTTPConduit cond = (HTTPConduit) ClientProxy.getClient(proxy).getConduit();
        cond.setAuthSupplier(new DigestAuthSupplier());
        int result = proxy.helloRequest("number");
        assertEquals(100, result);
    } finally {
        bus.shutdown(true);
    }
}
Also used : HTTPConduit(org.apache.cxf.transport.http.HTTPConduit) Bus(org.apache.cxf.Bus) DigestAuthSupplier(org.apache.cxf.transport.http.auth.DigestAuthSupplier) UseThreadBusFeature(org.jboss.wsf.stack.cxf.client.UseThreadBusFeature) QName(javax.xml.namespace.QName) Service(javax.xml.ws.Service) URL(java.net.URL) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test) JBossWSTest(org.jboss.wsf.test.JBossWSTest)

Example 17 with UseThreadBusFeature

use of org.jboss.wsf.stack.cxf.client.UseThreadBusFeature in project jbossws-cxf by jbossws.

the class FastInfosetTestCase method testInfosetUsingFeature.

@Test
@RunAsClient
@OperateOnDeployment(DEP1)
public void testInfosetUsingFeature() throws Exception {
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    ByteArrayOutputStream in = new ByteArrayOutputStream();
    PrintWriter pwIn = new PrintWriter(in);
    PrintWriter pwOut = new PrintWriter(out);
    Bus bus = BusFactory.newInstance().createBus();
    BusFactory.setThreadDefaultBus(bus);
    try {
        bus.getInInterceptors().add(new LoggingInInterceptor(pwIn));
        bus.getOutInterceptors().add(new LoggingOutInterceptor(pwOut));
        URL wsdlURL = new URL(baseURL + "HelloWorldService/HelloWorldFeatureImpl?wsdl");
        QName serviceName = new QName("http://org.jboss.ws/jaxws/cxf/fastinfoset", "HelloWorldFeatureService");
        Service service = Service.create(wsdlURL, serviceName, new UseThreadBusFeature());
        QName portQName = new QName("http://org.jboss.ws/jaxws/cxf/fastinfoset", "HelloWorldFeatureImplPort");
        HelloWorldFeature port = (HelloWorldFeature) service.getPort(portQName, HelloWorldFeature.class);
        assertEquals("helloworldFeature", port.echo("helloworldFeature"));
        assertTrue("request is expected fastinfoset", out.toString().indexOf("application/fastinfoset") > -1);
        assertTrue("response is expected fastinfoset", in.toString().indexOf("application/fastinfoset") > -1);
    } finally {
        bus.shutdown(true);
        pwOut.close();
        pwIn.close();
    }
}
Also used : Bus(org.apache.cxf.Bus) UseThreadBusFeature(org.jboss.wsf.stack.cxf.client.UseThreadBusFeature) LoggingOutInterceptor(org.apache.cxf.interceptor.LoggingOutInterceptor) QName(javax.xml.namespace.QName) LoggingInInterceptor(org.apache.cxf.interceptor.LoggingInInterceptor) Service(javax.xml.ws.Service) ByteArrayOutputStream(java.io.ByteArrayOutputStream) URL(java.net.URL) PrintWriter(java.io.PrintWriter) OperateOnDeployment(org.jboss.arquillian.container.test.api.OperateOnDeployment) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test) JBossWSTest(org.jboss.wsf.test.JBossWSTest)

Example 18 with UseThreadBusFeature

use of org.jboss.wsf.stack.cxf.client.UseThreadBusFeature in project jbossws-cxf by jbossws.

the class JBWS4046TestCase method callVersionService.

public String callVersionService(String path) throws Exception {
    URL wsdlURL = new URL(baseURL.toString() + "/" + path + "?wsdl");
    QName serviceName = new QName("http://org.jboss.ws/jaxws/cxf/jbws4046", "DemoService");
    Service service = Service.create(wsdlURL, serviceName, new UseThreadBusFeature());
    QName portQName = new QName("http://org.jboss.ws/jaxws/cxf/jbws4046", "DemoServicePort");
    return service.getPort(portQName, DemoInterface.class, null).version();
}
Also used : UseThreadBusFeature(org.jboss.wsf.stack.cxf.client.UseThreadBusFeature) QName(javax.xml.namespace.QName) Service(javax.xml.ws.Service) URL(java.net.URL)

Aggregations

UseThreadBusFeature (org.jboss.wsf.stack.cxf.client.UseThreadBusFeature)18 Service (javax.xml.ws.Service)17 URL (java.net.URL)16 QName (javax.xml.namespace.QName)16 Bus (org.apache.cxf.Bus)14 RunAsClient (org.jboss.arquillian.container.test.api.RunAsClient)12 JBossWSTest (org.jboss.wsf.test.JBossWSTest)12 Test (org.junit.Test)12 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6 PrintWriter (java.io.PrintWriter)6 LoggingInInterceptor (org.apache.cxf.interceptor.LoggingInInterceptor)6 LoggingOutInterceptor (org.apache.cxf.interceptor.LoggingOutInterceptor)3 HTTPConduit (org.apache.cxf.transport.http.HTTPConduit)3 OperateOnDeployment (org.jboss.arquillian.container.test.api.OperateOnDeployment)3 WebServiceException (javax.xml.ws.WebServiceException)2 DigestAuthSupplier (org.apache.cxf.transport.http.auth.DigestAuthSupplier)2 WrapThreadContextClassLoader (org.jboss.wsf.test.WrapThreadContextClassLoader)2 OutputStream (java.io.OutputStream)1 MalformedURLException (java.net.MalformedURLException)1 SocketTimeoutException (java.net.SocketTimeoutException)1