use of org.apache.cxf.service.model.BindingInfo in project cxf by apache.
the class ColocOutInterceptorTest method testColocOutIsColocatedPropertySet.
@Test
public void testColocOutIsColocatedPropertySet() throws Exception {
colocOut = new TestColocOutInterceptor1();
Bus bus = setupBus();
ServerRegistry sr = control.createMock(ServerRegistry.class);
EasyMock.expect(bus.getExtension(ServerRegistry.class)).andReturn(sr);
// Funtion Param
Server s1 = control.createMock(Server.class);
List<Server> list = new ArrayList<>();
list.add(s1);
Endpoint sep = control.createMock(Endpoint.class);
ex.put(Endpoint.class, sep);
QName op = new QName("E", "F");
QName intf = new QName("G", "H");
BindingInfo sbi = control.createMock(BindingInfo.class);
ServiceInfo ssi = new ServiceInfo();
InterfaceInfo sii = new InterfaceInfo(ssi, intf);
sii.addOperation(op);
OperationInfo soi = sii.getOperation(op);
ServiceInfo rsi = new ServiceInfo();
InterfaceInfo rii = new InterfaceInfo(rsi, intf);
rii.addOperation(op);
OperationInfo roi = rii.getOperation(op);
BindingOperationInfo sboi = control.createMock(BindingOperationInfo.class);
BindingOperationInfo rboi = control.createMock(BindingOperationInfo.class);
ex.put(BindingOperationInfo.class, sboi);
// Local var
Service ses = control.createMock(Service.class);
EndpointInfo sei = control.createMock(EndpointInfo.class);
Endpoint rep = control.createMock(Endpoint.class);
Service res = control.createMock(Service.class);
BindingInfo rbi = control.createMock(BindingInfo.class);
EndpointInfo rei = control.createMock(EndpointInfo.class);
EasyMock.expect(sr.getServers()).andReturn(list);
EasyMock.expect(sep.getService()).andReturn(ses);
EasyMock.expect(sep.getEndpointInfo()).andReturn(sei);
EasyMock.expect(s1.getEndpoint()).andReturn(rep);
EasyMock.expect(rep.getService()).andReturn(res);
EasyMock.expect(rep.getEndpointInfo()).andReturn(rei);
EasyMock.expect(ses.getName()).andReturn(new QName("A", "B"));
EasyMock.expect(res.getName()).andReturn(new QName("A", "B"));
EasyMock.expect(rei.getName()).andReturn(new QName("C", "D"));
EasyMock.expect(sei.getName()).andReturn(new QName("C", "D"));
EasyMock.expect(rei.getBinding()).andReturn(rbi);
EasyMock.expect(sboi.getName()).andReturn(op).anyTimes();
EasyMock.expect(sboi.getOperationInfo()).andReturn(soi);
EasyMock.expect(rboi.getName()).andReturn(op).anyTimes();
EasyMock.expect(rboi.getOperationInfo()).andReturn(roi);
EasyMock.expect(rbi.getOperation(op)).andReturn(rboi);
InterceptorChain chain = control.createMock(InterceptorChain.class);
msg.setInterceptorChain(chain);
EasyMock.expect(sboi.getBinding()).andReturn(sbi);
EasyMock.expect(sbi.getInterface()).andReturn(sii);
control.replay();
colocOut.handleMessage(msg);
assertTrue("COLOCATED property should be set", (Boolean) msg.get(COLOCATED));
assertEquals("Message.WSDL_OPERATION property should be set", op, msg.get(Message.WSDL_OPERATION));
assertEquals("Message.WSDL_INTERFACE property should be set", intf, msg.get(Message.WSDL_INTERFACE));
control.verify();
}
use of org.apache.cxf.service.model.BindingInfo in project cxf by apache.
the class AbstractJAXRSFactoryBean method createEndpointInfo.
/*
* EndpointInfo contains information form WSDL's physical part such as
* endpoint address, binding, transport etc. For JAX-RS based EndpointInfo,
* as there is no WSDL, these information are set manually, eg, default
* transport is http, binding is JAX-RS binding, endpoint address is from
* server mainline.
*/
protected EndpointInfo createEndpointInfo(Service service) throws BusException {
String transportId = getTransportId();
if (transportId == null && getAddress() != null) {
DestinationFactory df = getDestinationFactory();
if (df == null) {
DestinationFactoryManager dfm = getBus().getExtension(DestinationFactoryManager.class);
df = dfm.getDestinationFactoryForUri(getAddress());
super.setDestinationFactory(df);
}
if (df != null) {
transportId = df.getTransportIds().get(0);
}
}
// default to http transport
if (transportId == null) {
transportId = "http://cxf.apache.org/transports/http";
}
setTransportId(transportId);
// EndpointInfo ei = new EndpointInfo(service.getServiceInfos().get(0), transportId);
EndpointInfo ei = new EndpointInfo();
ei.setTransportId(transportId);
ei.setName(serviceFactory.getService().getName());
ei.setAddress(getAddress());
BindingInfo bindingInfo = createBindingInfo();
ei.setBinding(bindingInfo);
if (!StringUtils.isEmpty(publishedEndpointUrl)) {
ei.setProperty("publishedEndpointUrl", publishedEndpointUrl);
}
ei.setName(service.getName());
serviceFactory.sendEvent(FactoryBeanListener.Event.ENDPOINTINFO_CREATED, ei);
return ei;
}
use of org.apache.cxf.service.model.BindingInfo in project cxf by apache.
the class AbstractJAXRSFactoryBean method createBindingInfo.
protected BindingInfo createBindingInfo() {
BindingFactoryManager mgr = getBus().getExtension(BindingFactoryManager.class);
String binding = getBindingId();
BindingConfiguration bindingConfig = getBindingConfig();
if (binding == null && bindingConfig != null) {
binding = bindingConfig.getBindingId();
}
if (binding == null) {
binding = JAXRSBindingFactory.JAXRS_BINDING_ID;
}
try {
BindingFactory bindingFactory = mgr.getBindingFactory(binding);
setBindingFactory(bindingFactory);
BindingInfo bi = bindingFactory.createBindingInfo(serviceFactory.getService(), binding, bindingConfig);
for (BindingOperationInfo boi : bi.getOperations()) {
serviceFactory.sendEvent(FactoryBeanListener.Event.BINDING_OPERATION_CREATED, bi, boi, null);
}
serviceFactory.sendEvent(FactoryBeanListener.Event.BINDING_CREATED, bi);
return bi;
} catch (BusException ex) {
ex.printStackTrace();
// do nothing
}
return null;
}
use of org.apache.cxf.service.model.BindingInfo in project cxf by apache.
the class CodeFirstWSDLTest method createService.
private Definition createService(Class<?> clazz) throws Exception {
JaxWsImplementorInfo info = new JaxWsImplementorInfo(clazz);
ReflectionServiceFactoryBean bean = new JaxWsServiceFactoryBean(info);
Bus bus = getBus();
bean.setBus(bus);
Service service = bean.create();
InterfaceInfo i = service.getServiceInfos().get(0).getInterface();
assertEquals(5, i.getOperations().size());
ServerFactoryBean svrFactory = new ServerFactoryBean();
svrFactory.setBus(bus);
svrFactory.setServiceFactory(bean);
svrFactory.setServiceBean(clazz.newInstance());
svrFactory.setAddress(address);
svrFactory.create();
Collection<BindingInfo> bindings = service.getServiceInfos().get(0).getBindings();
assertEquals(1, bindings.size());
ServiceWSDLBuilder wsdlBuilder = new ServiceWSDLBuilder(bus, service.getServiceInfos().get(0));
return wsdlBuilder.build();
}
use of org.apache.cxf.service.model.BindingInfo in project cxf by apache.
the class MAPAggregatorTest method setUpUsingAddressing.
private void setUpUsingAddressing(Message message, Exchange exchange, boolean usingAddressing) {
setUpMessageExchange(message, exchange);
Endpoint endpoint = control.createMock(Endpoint.class);
endpoint.getOutInterceptors();
EasyMock.expectLastCall().andReturn(new ArrayList<Interceptor<? extends Message>>()).anyTimes();
setUpExchangeGet(exchange, Endpoint.class, endpoint);
EndpointInfo endpointInfo = control.createMock(EndpointInfo.class);
endpoint.getEndpointInfo();
EasyMock.expectLastCall().andReturn(endpointInfo).anyTimes();
List<ExtensibilityElement> endpointExts = new ArrayList<>();
endpointInfo.getExtensors(EasyMock.eq(ExtensibilityElement.class));
EasyMock.expectLastCall().andReturn(endpointExts).anyTimes();
BindingInfo bindingInfo = control.createMock(BindingInfo.class);
endpointInfo.getBinding();
EasyMock.expectLastCall().andReturn(bindingInfo).anyTimes();
bindingInfo.getExtensors(EasyMock.eq(ExtensibilityElement.class));
EasyMock.expectLastCall().andReturn(Collections.EMPTY_LIST).anyTimes();
ServiceInfo serviceInfo = control.createMock(ServiceInfo.class);
endpointInfo.getService();
EasyMock.expectLastCall().andReturn(serviceInfo).anyTimes();
serviceInfo.getExtensors(EasyMock.eq(ExtensibilityElement.class));
EasyMock.expectLastCall().andReturn(Collections.EMPTY_LIST).anyTimes();
ExtensibilityElement ext = control.createMock(ExtensibilityElement.class);
if (usingAddressing) {
QName elementType = usingAddressing ? Names.WSAW_USING_ADDRESSING_QNAME : new QName(SOAP_NAMESPACE, "encodingStyle");
ext.getElementType();
EasyMock.expectLastCall().andReturn(elementType).anyTimes();
endpointExts.add(ext);
}
}
Aggregations