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);
}
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);
}
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);
}
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());
}
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());
}
Aggregations