Search in sources :

Example 16 with Service

use of org.apache.cxf.service.Service in project cxf by apache.

the class GreeterTest method testEndpoint.

@Test
public void testEndpoint() throws Exception {
    ReflectionServiceFactoryBean bean = new JaxWsServiceFactoryBean();
    URL resource = getClass().getResource("/wsdl/hello_world.wsdl");
    assertNotNull(resource);
    bean.setWsdlURL(resource.toString());
    bean.setBus(bus);
    bean.setServiceClass(GreeterImpl.class);
    GreeterImpl greeter = new GreeterImpl();
    BeanInvoker invoker = new BeanInvoker(greeter);
    Service service = bean.create();
    assertEquals("SOAPService", service.getName().getLocalPart());
    assertEquals("http://apache.org/hello_world_soap_http", service.getName().getNamespaceURI());
    ServerFactoryBean svr = new ServerFactoryBean();
    svr.setBus(bus);
    svr.setServiceFactory(bean);
    svr.setInvoker(invoker);
    svr.create();
    Node response = invoke("http://localhost:9000/SoapContext/SoapPort", LocalTransportFactory.TRANSPORT_ID, "GreeterMessage.xml");
    assertEquals(1, greeter.getInvocationCount());
    assertNotNull(response);
    addNamespace("h", "http://apache.org/hello_world_soap_http/types");
    assertValid("/s:Envelope/s:Body", response);
    assertValid("//h:sayHiResponse", response);
}
Also used : JaxWsServiceFactoryBean(org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean) BeanInvoker(org.apache.cxf.service.invoker.BeanInvoker) Node(org.w3c.dom.Node) GreeterImpl(org.apache.hello_world_soap_http.GreeterImpl) Service(org.apache.cxf.service.Service) ServerFactoryBean(org.apache.cxf.frontend.ServerFactoryBean) ReflectionServiceFactoryBean(org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean) URL(java.net.URL) Test(org.junit.Test)

Example 17 with Service

use of org.apache.cxf.service.Service in project cxf by apache.

the class GreeterTest method testEndpointValidate.

@Test
public void testEndpointValidate() throws Exception {
    ReflectionServiceFactoryBean bean = new JaxWsServiceFactoryBean();
    URL resource = getClass().getResource("/wsdl/hello_world.wsdl");
    assertNotNull(resource);
    bean.setWsdlURL(resource.toString());
    bean.setBus(bus);
    bean.setServiceClass(GreeterImpl.class);
    bean.setValidate(true);
    GreeterImpl greeter = new GreeterImpl();
    BeanInvoker invoker = new BeanInvoker(greeter);
    Service service = bean.create();
    assertEquals("SOAPService", service.getName().getLocalPart());
    assertEquals("http://apache.org/hello_world_soap_http", service.getName().getNamespaceURI());
    ServerFactoryBean svr = new ServerFactoryBean();
    svr.setBus(bus);
    svr.setServiceFactory(bean);
    svr.setInvoker(invoker);
    svr.create();
    Node response = invoke("http://localhost:9000/SoapContext/SoapPort", LocalTransportFactory.TRANSPORT_ID, "GreeterMessage.xml");
    assertEquals(1, greeter.getInvocationCount());
    assertNotNull(response);
    addNamespace("h", "http://apache.org/hello_world_soap_http/types");
    assertValid("/s:Envelope/s:Body", response);
    assertValid("//h:sayHiResponse", response);
}
Also used : JaxWsServiceFactoryBean(org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean) BeanInvoker(org.apache.cxf.service.invoker.BeanInvoker) Node(org.w3c.dom.Node) GreeterImpl(org.apache.hello_world_soap_http.GreeterImpl) Service(org.apache.cxf.service.Service) ServerFactoryBean(org.apache.cxf.frontend.ServerFactoryBean) ReflectionServiceFactoryBean(org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean) URL(java.net.URL) Test(org.junit.Test)

Example 18 with Service

use of org.apache.cxf.service.Service in project cxf by apache.

the class JAXWSMethodInvokerTest method prepareJAXWSMethodInvoker.

private JAXWSMethodInvoker prepareJAXWSMethodInvoker(Exchange ex, Object serviceObject, Method serviceMethod) throws Throwable {
    EasyMock.reset(factory);
    factory.create(ex);
    EasyMock.expectLastCall().andReturn(serviceObject).anyTimes();
    factory.release(ex, serviceObject);
    EasyMock.expectLastCall().anyTimes();
    EasyMock.replay(factory);
    BindingOperationInfo boi = new BindingOperationInfo();
    ex.put(BindingOperationInfo.class, boi);
    Service serviceClass = EasyMock.createMock(Service.class);
    serviceClass.size();
    EasyMock.expectLastCall().andReturn(0).anyTimes();
    serviceClass.isEmpty();
    EasyMock.expectLastCall().andReturn(true).anyTimes();
    ex.put(Service.class, serviceClass);
    MethodDispatcher md = EasyMock.createMock(MethodDispatcher.class);
    serviceClass.get(MethodDispatcher.class.getName());
    EasyMock.expectLastCall().andReturn(md).anyTimes();
    md.getMethod(boi);
    EasyMock.expectLastCall().andReturn(serviceMethod).anyTimes();
    EasyMock.replay(md);
    EasyMock.replay(serviceClass);
    // initialize the contextCache
    ex.getInMessage().getContextualProperty("dummy");
    return new JAXWSMethodInvoker(factory);
}
Also used : BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) Service(org.apache.cxf.service.Service) MethodDispatcher(org.apache.cxf.service.invoker.MethodDispatcher)

Example 19 with Service

use of org.apache.cxf.service.Service in project cxf by apache.

the class ColocUtilTest method testGetOutInterceptorChain.

@Test
public void testGetOutInterceptorChain() throws Exception {
    PhaseManagerImpl phaseMgr = new PhaseManagerImpl();
    SortedSet<Phase> list = phaseMgr.getInPhases();
    ColocUtil.setPhases(list, Phase.SETUP, Phase.POST_LOGICAL);
    Endpoint ep = control.createMock(Endpoint.class);
    Service srv = control.createMock(Service.class);
    Exchange ex = new ExchangeImpl();
    ex.put(Bus.class, bus);
    ex.put(Endpoint.class, ep);
    ex.put(Service.class, srv);
    EasyMock.expect(ep.getOutInterceptors()).andReturn(new ArrayList<Interceptor<? extends Message>>()).atLeastOnce();
    EasyMock.expect(ep.getService()).andReturn(srv).atLeastOnce();
    EasyMock.expect(srv.getOutInterceptors()).andReturn(new ArrayList<Interceptor<? extends Message>>()).atLeastOnce();
    EasyMock.expect(bus.getOutInterceptors()).andReturn(new ArrayList<Interceptor<? extends Message>>()).atLeastOnce();
    control.replay();
    InterceptorChain chain = ColocUtil.getOutInterceptorChain(ex, list);
    control.verify();
    assertNotNull("Should have chain instance", chain);
    Iterator<Interceptor<? extends Message>> iter = chain.iterator();
    assertFalse("Should not have interceptors in chain", iter.hasNext());
}
Also used : Exchange(org.apache.cxf.message.Exchange) InterceptorChain(org.apache.cxf.interceptor.InterceptorChain) Phase(org.apache.cxf.phase.Phase) Endpoint(org.apache.cxf.endpoint.Endpoint) Message(org.apache.cxf.message.Message) ArrayList(java.util.ArrayList) Service(org.apache.cxf.service.Service) PhaseManagerImpl(org.apache.cxf.bus.managers.PhaseManagerImpl) Interceptor(org.apache.cxf.interceptor.Interceptor) ExchangeImpl(org.apache.cxf.message.ExchangeImpl) Test(org.junit.Test)

Example 20 with Service

use of org.apache.cxf.service.Service in project cxf by apache.

the class ColocUtilTest method testGetInInterceptorChain.

@Test
public void testGetInInterceptorChain() throws Exception {
    PhaseManagerImpl phaseMgr = new PhaseManagerImpl();
    SortedSet<Phase> list = phaseMgr.getInPhases();
    ColocUtil.setPhases(list, Phase.SETUP, Phase.POST_LOGICAL);
    Endpoint ep = control.createMock(Endpoint.class);
    Service srv = control.createMock(Service.class);
    Exchange ex = new ExchangeImpl();
    ex.put(Bus.class, bus);
    ex.put(Endpoint.class, ep);
    ex.put(Service.class, srv);
    EasyMock.expect(bus.getExtension(PhaseManager.class)).andReturn(phaseMgr);
    EasyMock.expect(ep.getInInterceptors()).andReturn(new ArrayList<Interceptor<? extends Message>>()).atLeastOnce();
    EasyMock.expect(ep.getService()).andReturn(srv).atLeastOnce();
    EasyMock.expect(srv.getInInterceptors()).andReturn(new ArrayList<Interceptor<? extends Message>>()).atLeastOnce();
    EasyMock.expect(bus.getInInterceptors()).andReturn(new ArrayList<Interceptor<? extends Message>>()).atLeastOnce();
    control.replay();
    InterceptorChain chain = ColocUtil.getInInterceptorChain(ex, list);
    control.verify();
    assertNotNull("Should have chain instance", chain);
    Iterator<Interceptor<? extends Message>> iter = chain.iterator();
    assertFalse("Should not have interceptors in chain", iter.hasNext());
    assertNotNull("OutFaultObserver should be set", chain.getFaultObserver());
}
Also used : Exchange(org.apache.cxf.message.Exchange) InterceptorChain(org.apache.cxf.interceptor.InterceptorChain) Phase(org.apache.cxf.phase.Phase) Endpoint(org.apache.cxf.endpoint.Endpoint) Message(org.apache.cxf.message.Message) ArrayList(java.util.ArrayList) Service(org.apache.cxf.service.Service) PhaseManagerImpl(org.apache.cxf.bus.managers.PhaseManagerImpl) Interceptor(org.apache.cxf.interceptor.Interceptor) ExchangeImpl(org.apache.cxf.message.ExchangeImpl) Test(org.junit.Test)

Aggregations

Service (org.apache.cxf.service.Service)270 Test (org.junit.Test)167 LoggingInInterceptor (org.apache.cxf.ext.logging.LoggingInInterceptor)138 LoggingOutInterceptor (org.apache.cxf.ext.logging.LoggingOutInterceptor)138 Client (org.apache.cxf.endpoint.Client)128 HashMap (java.util.HashMap)100 WSSSecurityProperties (org.apache.wss4j.stax.ext.WSSSecurityProperties)89 ArrayList (java.util.ArrayList)81 QName (javax.xml.namespace.QName)69 Properties (java.util.Properties)65 Endpoint (org.apache.cxf.endpoint.Endpoint)45 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)44 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)37 ServiceInfo (org.apache.cxf.service.model.ServiceInfo)33 Server (org.apache.cxf.endpoint.Server)27 OperationInfo (org.apache.cxf.service.model.OperationInfo)26 InterfaceInfo (org.apache.cxf.service.model.InterfaceInfo)23 Exchange (org.apache.cxf.message.Exchange)22 Bus (org.apache.cxf.Bus)21 JaxWsServerFactoryBean (org.apache.cxf.jaxws.JaxWsServerFactoryBean)21