use of org.apache.cxf.service.model.InterfaceInfo in project cxf by apache.
the class ReflectionServiceFactoryTest method testWrappedBuild.
@Test
public void testWrappedBuild() throws Exception {
Service service = createService(true);
ServiceInfo si = service.getServiceInfos().get(0);
InterfaceInfo intf = si.getInterface();
assertEquals(4, intf.getOperations().size());
String ns = si.getName().getNamespaceURI();
OperationInfo sayHelloOp = intf.getOperation(new QName(ns, "sayHello"));
assertNotNull(sayHelloOp);
assertEquals("sayHello", sayHelloOp.getInput().getName().getLocalPart());
List<MessagePartInfo> messageParts = sayHelloOp.getInput().getMessageParts();
assertEquals(1, messageParts.size());
assertNotNull(messageParts.get(0).getXmlSchema());
// test unwrapping
assertTrue(sayHelloOp.isUnwrappedCapable());
OperationInfo unwrappedOp = sayHelloOp.getUnwrappedOperation();
assertEquals("sayHello", unwrappedOp.getInput().getName().getLocalPart());
messageParts = unwrappedOp.getInput().getMessageParts();
assertEquals(0, messageParts.size());
// test output
messageParts = sayHelloOp.getOutput().getMessageParts();
assertEquals(1, messageParts.size());
assertEquals("sayHelloResponse", sayHelloOp.getOutput().getName().getLocalPart());
messageParts = unwrappedOp.getOutput().getMessageParts();
assertEquals("sayHelloResponse", unwrappedOp.getOutput().getName().getLocalPart());
assertEquals(1, messageParts.size());
MessagePartInfo mpi = messageParts.get(0);
assertEquals("return", mpi.getName().getLocalPart());
assertEquals(String.class, mpi.getTypeClass());
}
use of org.apache.cxf.service.model.InterfaceInfo in project cxf by apache.
the class ProviderServiceFactoryTest method testFromWSDL.
@Test
public void testFromWSDL() throws Exception {
URL resource = getClass().getResource("/wsdl/hello_world.wsdl");
assertNotNull(resource);
JaxWsImplementorInfo implInfo = new JaxWsImplementorInfo(HWSoapMessageProvider.class);
JaxWsServiceFactoryBean bean = new JaxWsServiceFactoryBean(implInfo);
bean.setWsdlURL(resource.toString());
Bus bus = getBus();
bean.setBus(bus);
bean.setServiceClass(HWSoapMessageProvider.class);
Service service = bean.create();
assertTrue(service.getInvoker() instanceof JAXWSMethodInvoker);
assertEquals("SOAPService", service.getName().getLocalPart());
assertEquals("http://apache.org/hello_world_soap_http", service.getName().getNamespaceURI());
InterfaceInfo intf = service.getServiceInfos().get(0).getInterface();
assertNotNull(intf);
JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
svrFactory.setBus(bus);
svrFactory.setServiceFactory(bean);
svrFactory.setStart(false);
ServerImpl server = (ServerImpl) svrFactory.create();
assertTrue(server.getEndpoint().getService().getInvoker() instanceof JAXWSMethodInvoker);
Endpoint endpoint = server.getEndpoint();
Binding binding = endpoint.getBinding();
assertTrue(binding instanceof SoapBinding);
}
use of org.apache.cxf.service.model.InterfaceInfo in project cxf by apache.
the class JaxWsServiceFactoryBeanTest method testWrappedDocLit.
@Test
public void testWrappedDocLit() throws Exception {
ReflectionServiceFactoryBean bean = new JaxWsServiceFactoryBean();
Bus bus = getBus();
bean.setBus(bus);
bean.setServiceClass(org.apache.hello_world_doc_lit.Greeter.class);
Service service = bean.create();
ServiceInfo si = service.getServiceInfos().get(0);
InterfaceInfo intf = si.getInterface();
assertEquals(4, intf.getOperations().size());
String ns = si.getName().getNamespaceURI();
assertEquals("http://apache.org/hello_world_doc_lit", ns);
OperationInfo greetMeOp = intf.getOperation(new QName(ns, "greetMe"));
assertNotNull(greetMeOp);
assertEquals("greetMe", greetMeOp.getInput().getName().getLocalPart());
assertEquals("http://apache.org/hello_world_doc_lit", greetMeOp.getInput().getName().getNamespaceURI());
List<MessagePartInfo> messageParts = greetMeOp.getInput().getMessageParts();
assertEquals(1, messageParts.size());
MessagePartInfo inMessagePart = messageParts.get(0);
assertEquals("http://apache.org/hello_world_doc_lit", inMessagePart.getName().getNamespaceURI());
assertEquals("http://apache.org/hello_world_doc_lit/types", inMessagePart.getElementQName().getNamespaceURI());
// test output
messageParts = greetMeOp.getOutput().getMessageParts();
assertEquals(1, messageParts.size());
assertEquals("greetMeResponse", greetMeOp.getOutput().getName().getLocalPart());
MessagePartInfo outMessagePart = messageParts.get(0);
// assertEquals("result", outMessagePart.getName().getLocalPart());
assertEquals("http://apache.org/hello_world_doc_lit", outMessagePart.getName().getNamespaceURI());
assertEquals("http://apache.org/hello_world_doc_lit/types", outMessagePart.getElementQName().getNamespaceURI());
OperationInfo greetMeOneWayOp = si.getInterface().getOperation(new QName(ns, "greetMeOneWay"));
assertEquals(1, greetMeOneWayOp.getInput().getMessageParts().size());
assertNull(greetMeOneWayOp.getOutput());
Collection<SchemaInfo> schemas = si.getSchemas();
assertEquals(1, schemas.size());
}
use of org.apache.cxf.service.model.InterfaceInfo in project cxf by apache.
the class ProxyTest method testLastMessage.
@Test
public void testLastMessage() throws NoSuchMethodException, RMException {
Method m = Proxy.class.getDeclaredMethod("invoke", new Class[] { OperationInfo.class, ProtocolVariation.class, Object[].class, Map.class, Level.class });
Proxy proxy = EasyMock.createMockBuilder(Proxy.class).addMockedMethod(m).createMock(control);
proxy.setReliableEndpoint(rme);
SourceSequence ss = control.createMock(SourceSequence.class);
EasyMock.expect(ss.getProtocol()).andReturn(ProtocolVariation.RM10WSA200408).anyTimes();
EasyMock.expect(ss.getTarget()).andReturn(null).anyTimes();
control.replay();
proxy.lastMessage(ss);
control.verify();
control.reset();
org.apache.cxf.ws.addressing.EndpointReferenceType target = RMUtils.createAnonymousReference();
EasyMock.expect(ss.getTarget()).andReturn(target).anyTimes();
control.replay();
proxy.lastMessage(ss);
control.verify();
control.reset();
target = RMUtils.createReference("http://localhost:9000/greeterPort");
EasyMock.expect(ss.getTarget()).andReturn(target).anyTimes();
EasyMock.expect(ss.getProtocol()).andReturn(ProtocolVariation.RM10WSA200408).anyTimes();
Endpoint endpoint = control.createMock(Endpoint.class);
EasyMock.expect(rme.getEndpoint(ProtocolVariation.RM10WSA200408)).andReturn(endpoint).anyTimes();
EndpointInfo epi = control.createMock(EndpointInfo.class);
EasyMock.expect(endpoint.getEndpointInfo()).andReturn(epi).anyTimes();
ServiceInfo si = control.createMock(ServiceInfo.class);
EasyMock.expect(epi.getService()).andReturn(si).anyTimes();
InterfaceInfo ii = control.createMock(InterfaceInfo.class);
EasyMock.expect(si.getInterface()).andReturn(ii).anyTimes();
OperationInfo oi = control.createMock(OperationInfo.class);
EasyMock.expect(ii.getOperation(RM10Constants.CLOSE_SEQUENCE_QNAME)).andReturn(oi).anyTimes();
expectInvokeWithContext(proxy, oi, null);
control.replay();
proxy.lastMessage(ss);
}
use of org.apache.cxf.service.model.InterfaceInfo in project cxf by apache.
the class ProxyTest method testAcknowledge.
@Test
public void testAcknowledge() throws NoSuchMethodException, RMException {
Method m = Proxy.class.getDeclaredMethod("invoke", new Class[] { OperationInfo.class, ProtocolVariation.class, Object[].class, Map.class });
Proxy proxy = EasyMock.createMockBuilder(Proxy.class).addMockedMethod(m).createMock(control);
proxy.setReliableEndpoint(rme);
DestinationSequence ds = control.createMock(DestinationSequence.class);
EasyMock.expect(ds.getProtocol()).andReturn(ProtocolVariation.RM10WSA200408).anyTimes();
EndpointReferenceType acksToEPR = control.createMock(EndpointReferenceType.class);
EasyMock.expect(ds.getAcksTo()).andReturn(acksToEPR).anyTimes();
AttributedURIType acksToURI = control.createMock(AttributedURIType.class);
EasyMock.expect(acksToEPR.getAddress()).andReturn(acksToURI).anyTimes();
String acksToAddress = "acksTo";
EasyMock.expect(acksToURI.getValue()).andReturn(acksToAddress).anyTimes();
Endpoint endpoint = control.createMock(Endpoint.class);
EasyMock.expect(rme.getEndpoint(ProtocolVariation.RM10WSA200408)).andReturn(endpoint).anyTimes();
EndpointInfo epi = control.createMock(EndpointInfo.class);
EasyMock.expect(endpoint.getEndpointInfo()).andReturn(epi).anyTimes();
ServiceInfo si = control.createMock(ServiceInfo.class);
EasyMock.expect(epi.getService()).andReturn(si).anyTimes();
InterfaceInfo ii = control.createMock(InterfaceInfo.class);
EasyMock.expect(si.getInterface()).andReturn(ii).anyTimes();
OperationInfo oi = control.createMock(OperationInfo.class);
EasyMock.expect(ii.getOperation(RM10Constants.SEQUENCE_ACK_QNAME)).andReturn(oi).anyTimes();
expectInvoke(proxy, oi, null);
control.replay();
proxy.acknowledge(ds);
}
Aggregations