use of org.apache.cxf.service.model.InterfaceInfo 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);
assertEquals("COLOCATED property should be set", Boolean.TRUE, 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.InterfaceInfo in project cxf by apache.
the class ReflectionServiceFactoryTest method testUnwrappedBuild.
@Test
public void testUnwrappedBuild() throws Exception {
Service service = createService(false);
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(0, messageParts.size());
// test output
messageParts = sayHelloOp.getOutput().getMessageParts();
assertEquals(1, messageParts.size());
assertEquals("sayHelloResponse", sayHelloOp.getOutput().getName().getLocalPart());
MessagePartInfo mpi = messageParts.get(0);
assertEquals("return", mpi.getName().getLocalPart());
assertEquals(String.class, mpi.getTypeClass());
OperationInfo op = si.getInterface().getOperation(new QName(ns, "echoWithExchange"));
assertEquals(1, op.getInput().getMessageParts().size());
}
use of org.apache.cxf.service.model.InterfaceInfo in project cxf by apache.
the class AbstractLoggingInterceptor method getMessageLogger.
Logger getMessageLogger(Message message) {
if (isLoggingDisabledNow(message)) {
return null;
}
Endpoint ep = message.getExchange().getEndpoint();
if (ep == null || ep.getEndpointInfo() == null) {
return getLogger();
}
EndpointInfo endpoint = ep.getEndpointInfo();
if (endpoint.getService() == null) {
return getLogger();
}
Logger logger = endpoint.getProperty("MessageLogger", Logger.class);
if (logger == null) {
String serviceName = endpoint.getService().getName().getLocalPart();
InterfaceInfo iface = endpoint.getService().getInterface();
String portName = endpoint.getName().getLocalPart();
String portTypeName = iface.getName().getLocalPart();
String logName = "org.apache.cxf.services." + serviceName + "." + portName + "." + portTypeName;
logger = LogUtils.getL7dLogger(this.getClass(), null, logName);
endpoint.setProperty("MessageLogger", logger);
}
return logger;
}
use of org.apache.cxf.service.model.InterfaceInfo 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.InterfaceInfo in project cxf by apache.
the class ProviderServiceFactoryTest method testXMLBindingFromCode.
@Test
public void testXMLBindingFromCode() throws Exception {
JaxWsServiceFactoryBean bean = new JaxWsServiceFactoryBean();
bean.setServiceClass(DOMSourcePayloadProvider.class);
bean.setBus(getBus());
bean.setInvoker(new JAXWSMethodInvoker(new DOMSourcePayloadProvider()));
Service service = bean.create();
assertEquals("DOMSourcePayloadProviderService", service.getName().getLocalPart());
InterfaceInfo intf = service.getServiceInfos().get(0).getInterface();
assertNotNull(intf);
JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
svrFactory.setBus(getBus());
svrFactory.setServiceFactory(bean);
String address = "http://localhost:9000/test";
svrFactory.setAddress(address);
svrFactory.setTransportId(LocalTransportFactory.TRANSPORT_ID);
ServerImpl server = (ServerImpl) svrFactory.create();
assertEquals(1, service.getServiceInfos().get(0).getEndpoints().size());
Endpoint endpoint = server.getEndpoint();
Binding binding = endpoint.getBinding();
assertTrue(binding instanceof XMLBinding);
Node res = invoke(address, LocalTransportFactory.TRANSPORT_ID, "/org/apache/cxf/jaxws/provider/sayHi.xml");
addNamespace("j", "http://service.jaxws.cxf.apache.org/");
assertValid("/j:sayHi", res);
}
Aggregations