use of org.apache.cxf.service.model.BindingInfo in project cxf by apache.
the class RMEndpointTest method testGetUsingAddressing.
@Test
public void testGetUsingAddressing() {
EndpointInfo ei = null;
control.replay();
assertNull(rme.getUsingAddressing(ei));
control.verify();
control.reset();
ExtensibilityElement ua = control.createMock(ExtensibilityElement.class);
ei = control.createMock(EndpointInfo.class);
List<ExtensibilityElement> noExts = new ArrayList<>();
List<ExtensibilityElement> exts = new ArrayList<>();
exts.add(ua);
EasyMock.expect(ei.getExtensors(ExtensibilityElement.class)).andReturn(noExts);
BindingInfo bi = control.createMock(BindingInfo.class);
EasyMock.expect(ei.getBinding()).andReturn(bi).times(2);
EasyMock.expect(bi.getExtensors(ExtensibilityElement.class)).andReturn(noExts);
ServiceInfo si = control.createMock(ServiceInfo.class);
EasyMock.expect(ei.getService()).andReturn(si).times(2);
EasyMock.expect(si.getExtensors(ExtensibilityElement.class)).andReturn(exts);
EasyMock.expect(ua.getElementType()).andReturn(Names.WSAW_USING_ADDRESSING_QNAME);
control.replay();
assertSame(ua, rme.getUsingAddressing(ei));
}
use of org.apache.cxf.service.model.BindingInfo in project cxf by apache.
the class ProxyTest method testInvoke.
@Test
public void testInvoke() throws Exception {
Method m = Proxy.class.getDeclaredMethod("createClient", new Class[] { Bus.class, Endpoint.class, ProtocolVariation.class, Conduit.class, org.apache.cxf.ws.addressing.EndpointReferenceType.class });
Proxy proxy = EasyMock.createMockBuilder(Proxy.class).addMockedMethod(m).createMock(control);
proxy.setReliableEndpoint(rme);
RMManager manager = control.createMock(RMManager.class);
EasyMock.expect(rme.getManager()).andReturn(manager).anyTimes();
Bus bus = control.createMock(Bus.class);
EasyMock.expect(manager.getBus()).andReturn(bus).anyTimes();
Endpoint endpoint = control.createMock(Endpoint.class);
EasyMock.expect(rme.getEndpoint(ProtocolVariation.RM10WSA200408)).andReturn(endpoint).anyTimes();
BindingInfo bi = control.createMock(BindingInfo.class);
EasyMock.expect(rme.getBindingInfo(ProtocolVariation.RM10WSA200408)).andReturn(bi).anyTimes();
Conduit conduit = control.createMock(Conduit.class);
EasyMock.expect(rme.getConduit()).andReturn(conduit).anyTimes();
org.apache.cxf.ws.addressing.EndpointReferenceType replyTo = control.createMock(org.apache.cxf.ws.addressing.EndpointReferenceType.class);
EasyMock.expect(rme.getReplyTo()).andReturn(replyTo).anyTimes();
OperationInfo oi = control.createMock(OperationInfo.class);
BindingOperationInfo boi = control.createMock(BindingOperationInfo.class);
EasyMock.expect(bi.getOperation(oi)).andReturn(boi).anyTimes();
Client client = control.createMock(Client.class);
EasyMock.expect(client.getRequestContext()).andReturn(new HashMap<String, Object>()).anyTimes();
EasyMock.expect(proxy.createClient(bus, endpoint, ProtocolVariation.RM10WSA200408, conduit, replyTo)).andReturn(client).anyTimes();
Object[] args = new Object[] {};
Map<String, Object> context = new HashMap<>();
Object[] results = new Object[] { "a", "b", "c" };
Exchange exchange = control.createMock(Exchange.class);
EasyMock.expect(client.invoke(boi, args, context, exchange)).andReturn(results).anyTimes();
control.replay();
assertEquals("a", proxy.invoke(oi, ProtocolVariation.RM10WSA200408, args, context, exchange));
}
use of org.apache.cxf.service.model.BindingInfo in project cxf by apache.
the class WSDLServiceBuilder method buildBinding.
public BindingInfo buildBinding(ServiceInfo service, Binding binding) {
BindingInfo bi = null;
StringBuilder ns = new StringBuilder(100);
BindingFactory factory = WSDLServiceUtils.getBindingFactory(binding, bus, ns);
if (factory instanceof WSDLBindingFactory) {
WSDLBindingFactory wFactory = (WSDLBindingFactory) factory;
bi = wFactory.createBindingInfo(service, binding, ns.toString());
copyExtensors(bi, binding.getExtensibilityElements());
copyExtensionAttributes(bi, binding);
}
if (bi == null) {
boolean onlyExtensors = false;
if (factory instanceof AbstractBindingFactory) {
bi = ((AbstractBindingFactory) factory).createBindingInfo(service, ns.toString(), null);
onlyExtensors = true;
} else {
bi = new BindingInfo(service, ns.toString());
}
bi.setName(binding.getQName());
copyExtensors(bi, binding.getExtensibilityElements());
copyExtensionAttributes(bi, binding);
for (BindingOperation bop : cast(binding.getBindingOperations(), BindingOperation.class)) {
if (LOG.isLoggable(Level.FINER)) {
LOG.finer("binding operation name is " + bop.getName());
}
String inName = null;
String outName = null;
if (bop.getBindingInput() != null) {
inName = bop.getBindingInput().getName();
}
if (bop.getBindingOutput() != null) {
outName = bop.getBindingOutput().getName();
}
final BindingOperationInfo bop2;
if (onlyExtensors) {
bop2 = bi.getOperation(new QName(binding.getQName().getNamespaceURI(), bop.getName()));
} else {
bop2 = bi.buildOperation(new QName(binding.getQName().getNamespaceURI(), bop.getName()), inName, outName);
if (bop2 != null) {
bi.addOperation(bop2);
}
}
if (bop2 != null) {
copyExtensors(bop2, bop.getExtensibilityElements());
copyExtensionAttributes(bop2, bop);
if (bop.getBindingInput() != null) {
copyExtensors(bop2.getInput(), bop.getBindingInput().getExtensibilityElements());
copyExtensionAttributes(bop2.getInput(), bop.getBindingInput());
handleHeader(bop2.getInput());
}
if (bop.getBindingOutput() != null) {
copyExtensors(bop2.getOutput(), bop.getBindingOutput().getExtensibilityElements());
copyExtensionAttributes(bop2.getOutput(), bop.getBindingOutput());
handleHeader(bop2.getOutput());
}
for (BindingFault f : cast(bop.getBindingFaults().values(), BindingFault.class)) {
BindingFaultInfo bif = bop2.getFault(new QName(service.getTargetNamespace(), f.getName()));
copyExtensors(bif, bop.getBindingFault(f.getName()).getExtensibilityElements());
copyExtensionAttributes(bif, bop.getBindingFault(f.getName()));
}
}
}
}
service.addBinding(bi);
DescriptionInfo d = service.getDescription();
if (null != d) {
d.getDescribed().add(bi);
}
return bi;
}
use of org.apache.cxf.service.model.BindingInfo in project cxf by apache.
the class DocLiteralInInterceptorTest method testUnmarshalSourceData.
@Test
public void testUnmarshalSourceData() throws Exception {
XMLStreamReader reader = StaxUtils.createXMLStreamReader(getClass().getResourceAsStream("resources/multiPartDocLitBareReq.xml"));
assertEquals(XMLStreamConstants.START_ELEMENT, reader.nextTag());
XMLStreamReader filteredReader = new PartialXMLStreamReader(reader, new QName("http://schemas.xmlsoap.org/soap/envelope/", "Body"));
// advance the xml reader to the message parts
StaxUtils.read(filteredReader);
assertEquals(XMLStreamConstants.START_ELEMENT, reader.nextTag());
Message m = new MessageImpl();
Exchange exchange = new ExchangeImpl();
Service service = control.createMock(Service.class);
exchange.put(Service.class, service);
EasyMock.expect(service.getDataBinding()).andReturn(new SourceDataBinding());
EasyMock.expect(service.size()).andReturn(0).anyTimes();
EasyMock.expect(service.isEmpty()).andReturn(true).anyTimes();
Endpoint endpoint = control.createMock(Endpoint.class);
exchange.put(Endpoint.class, endpoint);
OperationInfo operationInfo = new OperationInfo();
operationInfo.setProperty("operation.is.synthetic", Boolean.TRUE);
MessageInfo messageInfo = new MessageInfo(operationInfo, Type.INPUT, new QName("http://foo.com", "bar"));
messageInfo.addMessagePart(new MessagePartInfo(new QName("http://foo.com", "partInfo1"), null));
messageInfo.addMessagePart(new MessagePartInfo(new QName("http://foo.com", "partInfo2"), null));
messageInfo.addMessagePart(new MessagePartInfo(new QName("http://foo.com", "partInfo3"), null));
messageInfo.addMessagePart(new MessagePartInfo(new QName("http://foo.com", "partInfo4"), null));
for (MessagePartInfo mpi : messageInfo.getMessageParts()) {
mpi.setMessageContainer(messageInfo);
}
operationInfo.setInput("inputName", messageInfo);
BindingOperationInfo boi = new BindingOperationInfo(null, operationInfo);
exchange.put(BindingOperationInfo.class, boi);
EndpointInfo endpointInfo = control.createMock(EndpointInfo.class);
BindingInfo binding = control.createMock(BindingInfo.class);
EasyMock.expect(endpoint.getEndpointInfo()).andReturn(endpointInfo).anyTimes();
EasyMock.expect(endpointInfo.getBinding()).andReturn(binding).anyTimes();
EasyMock.expect(binding.getProperties()).andReturn(new HashMap<String, Object>()).anyTimes();
EasyMock.expect(endpointInfo.getProperties()).andReturn(new HashMap<String, Object>()).anyTimes();
EasyMock.expect(endpoint.size()).andReturn(0).anyTimes();
EasyMock.expect(endpoint.isEmpty()).andReturn(true).anyTimes();
ServiceInfo serviceInfo = control.createMock(ServiceInfo.class);
EasyMock.expect(endpointInfo.getService()).andReturn(serviceInfo).anyTimes();
EasyMock.expect(serviceInfo.getName()).andReturn(new QName("http://foo.com", "service")).anyTimes();
InterfaceInfo interfaceInfo = control.createMock(InterfaceInfo.class);
EasyMock.expect(serviceInfo.getInterface()).andReturn(interfaceInfo).anyTimes();
EasyMock.expect(interfaceInfo.getName()).andReturn(new QName("http://foo.com", "interface")).anyTimes();
EasyMock.expect(endpointInfo.getName()).andReturn(new QName("http://foo.com", "endpoint")).anyTimes();
EasyMock.expect(endpointInfo.getProperty("URI", URI.class)).andReturn(new URI("dummy")).anyTimes();
List<OperationInfo> operations = new ArrayList<>();
EasyMock.expect(interfaceInfo.getOperations()).andReturn(operations).anyTimes();
m.setExchange(exchange);
m.put(Message.SCHEMA_VALIDATION_ENABLED, false);
m.setContent(XMLStreamReader.class, reader);
control.replay();
new DocLiteralInInterceptor().handleMessage(m);
MessageContentsList params = (MessageContentsList) m.getContent(List.class);
assertEquals(4, params.size());
assertEquals("StringDefaultInputElem", ((DOMSource) params.get(0)).getNode().getFirstChild().getNodeName());
assertEquals("IntParamInElem", ((DOMSource) params.get(1)).getNode().getFirstChild().getNodeName());
}
use of org.apache.cxf.service.model.BindingInfo in project cxf by apache.
the class WSDLServiceBuilderTest method testBare.
@Test
public void testBare() throws Exception {
setUpWSDL(BARE_WSDL_PATH, 0);
BindingInfo bindingInfo = serviceInfo.getBindings().iterator().next();
Collection<BindingOperationInfo> bindingOperationInfos = bindingInfo.getOperations();
assertNotNull(bindingOperationInfos);
assertEquals(bindingOperationInfos.size(), 1);
LOG.info("the binding operation is " + bindingOperationInfos.iterator().next().getName());
QName name = new QName(serviceInfo.getName().getNamespaceURI(), "greetMe");
BindingOperationInfo greetMe = bindingInfo.getOperation(name);
assertNotNull(greetMe);
assertEquals("greetMe OperationInfo name error", greetMe.getName(), name);
assertFalse("greetMe should be a Unwrapped operation ", greetMe.isUnwrappedCapable());
assertNotNull(serviceInfo.getXmlSchemaCollection());
control.verify();
}
Aggregations