Search in sources :

Example 21 with ServerFactoryBean

use of org.apache.cxf.frontend.ServerFactoryBean in project cxf by apache.

the class RountripTest method testServerFactoryBean.

@Test
public void testServerFactoryBean() throws Exception {
    ServerFactoryBean svrBean = new ServerFactoryBean();
    svrBean.setAddress("http://localhost/Hello");
    svrBean.setTransportId("http://schemas.xmlsoap.org/soap/http");
    svrBean.setServiceBean(new HelloServiceImpl());
    svrBean.setServiceClass(HelloService.class);
    svrBean.setBus(getBus());
    svrBean.create();
    ClientProxyFactoryBean proxyFactory = new ClientProxyFactoryBean();
    ClientFactoryBean clientBean = proxyFactory.getClientFactoryBean();
    clientBean.setAddress("http://localhost/Hello");
    clientBean.setTransportId("http://schemas.xmlsoap.org/soap/http");
    clientBean.setServiceClass(HelloService.class);
    clientBean.setBus(getBus());
    HelloService client = (HelloService) proxyFactory.create();
    assertEquals("hello", client.sayHello());
    assertEquals("hello", client.echo("hello"));
}
Also used : ClientFactoryBean(org.apache.cxf.frontend.ClientFactoryBean) ClientProxyFactoryBean(org.apache.cxf.frontend.ClientProxyFactoryBean) ServerFactoryBean(org.apache.cxf.frontend.ServerFactoryBean) Test(org.junit.Test)

Example 22 with ServerFactoryBean

use of org.apache.cxf.frontend.ServerFactoryBean in project cxf by apache.

the class ServerFactoryTest method testSetDF.

@Test
public void testSetDF() throws Exception {
    ServerFactoryBean svrBean = new ServerFactoryBean();
    svrBean.setAddress("http://localhost/Hello");
    svrBean.setServiceClass(HelloService.class);
    svrBean.setServiceBean(new HelloServiceImpl());
    svrBean.setBus(getBus());
    svrBean.setDestinationFactory(new CustomDestinationFactory(getBus()));
    ServerImpl server = (ServerImpl) svrBean.create();
    assertTrue(server.getDestination() instanceof CustomDestination);
}
Also used : ServerImpl(org.apache.cxf.endpoint.ServerImpl) ServerFactoryBean(org.apache.cxf.frontend.ServerFactoryBean) Test(org.junit.Test)

Example 23 with ServerFactoryBean

use of org.apache.cxf.frontend.ServerFactoryBean in project cxf by apache.

the class ServerFactoryTest method testCXF1758.

@Test
public void testCXF1758() throws Exception {
    ServerFactoryBean svrBean = new ServerFactoryBean();
    svrBean.setAddress("http://localhost/Generics");
    svrBean.setServiceBean(new TestServiceImpl<String>() {
    });
    svrBean.setBus(getBus());
    ServerImpl server = (ServerImpl) svrBean.create();
    // XMLUtils.printDOM(getWSDLDocument(server));
    assertValid("//xsd:schema/xsd:complexType[@name='open']/xsd:sequence/" + "xsd:element[@type='xsd:string']", getWSDLDocument(server));
}
Also used : ServerImpl(org.apache.cxf.endpoint.ServerImpl) ServerFactoryBean(org.apache.cxf.frontend.ServerFactoryBean) Test(org.junit.Test)

Example 24 with ServerFactoryBean

use of org.apache.cxf.frontend.ServerFactoryBean in project cxf by apache.

the class ServerFactoryTest method testJaxbExtraClass.

@Test
public void testJaxbExtraClass() throws Exception {
    ServerFactoryBean svrBean = new ServerFactoryBean();
    svrBean.setAddress("http://localhost/Hello");
    svrBean.setServiceClass(HelloServiceImpl.class);
    svrBean.setBus(getBus());
    Map<String, Object> props = svrBean.getProperties();
    if (props == null) {
        props = new HashMap<>();
    }
    props.put("jaxb.additionalContextClasses", new Class[] { GreetMe.class, GreetMeOneWay.class });
    svrBean.setProperties(props);
    Server serv = svrBean.create();
    Class<?>[] extraClass = ((JAXBDataBinding) serv.getEndpoint().getService().getDataBinding()).getExtraClass();
    assertEquals(extraClass.length, 2);
    assertEquals(extraClass[0], GreetMe.class);
    assertEquals(extraClass[1], GreetMeOneWay.class);
}
Also used : Server(org.apache.cxf.endpoint.Server) ServerFactoryBean(org.apache.cxf.frontend.ServerFactoryBean) JAXBDataBinding(org.apache.cxf.jaxb.JAXBDataBinding) Test(org.junit.Test)

Example 25 with ServerFactoryBean

use of org.apache.cxf.frontend.ServerFactoryBean in project cxf by apache.

the class QueryHandlerTest method before.

@Before
public void before() {
    ServerFactoryBean serverFactoryBean = getBean(ServerFactoryBean.class, "hw-service-endpoint");
    hwEndpoint = serverFactoryBean.create().getEndpoint();
    serverFactoryBean = getBean(ServerFactoryBean.class, "dlb-service-endpoint");
    dlbEndpoint = serverFactoryBean.create().getEndpoint();
}
Also used : ServerFactoryBean(org.apache.cxf.frontend.ServerFactoryBean) Before(org.junit.Before)

Aggregations

ServerFactoryBean (org.apache.cxf.frontend.ServerFactoryBean)48 Test (org.junit.Test)16 Server (org.apache.cxf.endpoint.Server)9 Before (org.junit.Before)9 BeforeClass (org.junit.BeforeClass)9 JaxWsServerFactoryBean (org.apache.cxf.jaxws.JaxWsServerFactoryBean)8 AegisDatabinding (org.apache.cxf.aegis.databinding.AegisDatabinding)6 QName (javax.xml.namespace.QName)5 JaxWsServiceFactoryBean (org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean)5 Service (org.apache.cxf.service.Service)5 Node (org.w3c.dom.Node)5 Bus (org.apache.cxf.Bus)4 ReflectionServiceFactoryBean (org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean)4 HashMap (java.util.HashMap)3 ServerImpl (org.apache.cxf.endpoint.ServerImpl)3 ClientProxyFactoryBean (org.apache.cxf.frontend.ClientProxyFactoryBean)3 BeanInvoker (org.apache.cxf.service.invoker.BeanInvoker)3 AbstractCXFTest (org.apache.cxf.test.AbstractCXFTest)3 ServiceWSDLBuilder (org.apache.cxf.wsdl11.ServiceWSDLBuilder)3 URL (java.net.URL)2