use of org.apache.cxf.service.Service in project cxf by apache.
the class RMEndpointTest method testCreateService.
@Test
public void testCreateService() {
Service as = control.createMock(Service.class);
EasyMock.expect(ae.getService()).andReturn(as);
control.replay();
rme.createServices();
Service s = rme.getService(ProtocolVariation.RM10WSA200408);
assertNotNull(s);
WrappedService ws = (WrappedService) s;
assertSame(as, ws.getWrappedService());
assertSame(rme.getServant(), s.getInvoker());
verifyService();
}
use of org.apache.cxf.service.Service in project cxf by apache.
the class RMEndpointTest method testCreateEndpoint.
@Test
public void testCreateEndpoint() throws NoSuchMethodException, EndpointException {
Method m = RMEndpoint.class.getDeclaredMethod("getUsingAddressing", new Class[] { EndpointInfo.class });
Service as = control.createMock(Service.class);
EndpointInfo aei = new EndpointInfo();
ae = new EndpointImpl(null, as, aei);
rme = EasyMock.createMockBuilder(RMEndpoint.class).withConstructor(manager, ae).addMockedMethod(m).createMock(control);
rme.setAplicationEndpoint(ae);
rme.setManager(manager);
SoapBindingInfo bi = control.createMock(SoapBindingInfo.class);
aei.setBinding(bi);
SoapVersion sv = Soap11.getInstance();
EasyMock.expect(bi.getSoapVersion()).andReturn(sv);
String ns = "http://schemas.xmlsoap.org/wsdl/soap/";
EasyMock.expect(bi.getBindingId()).andReturn(ns);
aei.setTransportId(ns);
String addr = "addr";
aei.setAddress(addr);
Object ua = new Object();
EasyMock.expect(rme.getUsingAddressing(aei)).andReturn(ua);
control.replay();
rme.createServices();
rme.createEndpoints(null);
Endpoint e = rme.getEndpoint(ProtocolVariation.RM10WSA200408);
WrappedEndpoint we = (WrappedEndpoint) e;
assertSame(ae, we.getWrappedEndpoint());
Service s = rme.getService(ProtocolVariation.RM10WSA200408);
assertEquals(1, s.getEndpoints().size());
assertSame(e, s.getEndpoints().get(RM10Constants.PORT_NAME));
}
use of org.apache.cxf.service.Service in project cxf by apache.
the class RMManagerTest method setUpRecoverReliableEndpoint.
void setUpRecoverReliableEndpoint(Endpoint endpoint, Conduit conduit, SourceSequence ss, DestinationSequence ds, RMMessage m) throws IOException {
RMStore store = control.createMock(RMStore.class);
RetransmissionQueue oqueue = control.createMock(RetransmissionQueue.class);
RedeliveryQueue iqueue = control.createMock(RedeliveryQueue.class);
manager.setStore(store);
manager.setRetransmissionQueue(oqueue);
manager.setRedeliveryQueue(iqueue);
Collection<SourceSequence> sss = new ArrayList<>();
if (null != ss) {
sss.add(ss);
}
EasyMock.expect(store.getSourceSequences("{S}s.{P}p@cxf")).andReturn(sss);
if (null == ss) {
return;
}
Collection<DestinationSequence> dss = new ArrayList<>();
if (null != ds) {
dss.add(ds);
}
EasyMock.expect(store.getDestinationSequences("{S}s.{P}p@cxf")).andReturn(dss);
if (null == ds) {
return;
}
Collection<RMMessage> ms = new ArrayList<>();
if (null != m) {
ms.add(m);
}
Identifier id = new Identifier();
id.setValue("S1");
EasyMock.expect(ss.getIdentifier()).andReturn(id).times(null == m ? 1 : 2);
EasyMock.expect(ss.getProtocol()).andReturn(ProtocolVariation.RM10WSA200408).anyTimes();
EasyMock.expect(store.getMessages(id, true)).andReturn(ms);
RMEndpoint rme = control.createMock(RMEndpoint.class);
EasyMock.expect(manager.createReliableEndpoint(endpoint)).andReturn(rme);
Source source = control.createMock(Source.class);
EasyMock.expect(rme.getSource()).andReturn(source).anyTimes();
Destination destination = control.createMock(Destination.class);
EasyMock.expect(rme.getDestination()).andReturn(destination);
destination.addSequence(ds, false);
EasyMock.expectLastCall();
Service service = control.createMock(Service.class);
EasyMock.expect(endpoint.getService()).andReturn(service).anyTimes();
Binding binding = control.createMock(Binding.class);
EasyMock.expect(endpoint.getBinding()).andReturn(binding).anyTimes();
EasyMock.expect(ss.isLastMessage()).andReturn(true).anyTimes();
EasyMock.expect(ss.getCurrentMessageNr()).andReturn(Long.valueOf(10)).anyTimes();
if (null == m) {
return;
}
EasyMock.expect(m.getMessageNumber()).andReturn(Long.valueOf(10)).times(2);
if (null == conduit) {
EasyMock.expect(m.getTo()).andReturn("toAddress");
}
InputStream is = new ByteArrayInputStream(new byte[0]);
CachedOutputStream cos = new CachedOutputStream();
IOUtils.copy(is, cos);
cos.flush();
is.close();
EasyMock.expect(m.getContent()).andReturn(cos).anyTimes();
oqueue.addUnacknowledged(EasyMock.isA(Message.class));
EasyMock.expectLastCall();
oqueue.start();
EasyMock.expectLastCall();
iqueue.start();
EasyMock.expectLastCall();
}
use of org.apache.cxf.service.Service in project cxf by apache.
the class ReflectionServiceFactoryBean method createEndpoints.
protected void createEndpoints() {
Service service = getService();
BindingFactoryManager bfm = getBus().getExtension(BindingFactoryManager.class);
for (ServiceInfo inf : service.getServiceInfos()) {
for (EndpointInfo ei : inf.getEndpoints()) {
for (BindingOperationInfo boi : ei.getBinding().getOperations()) {
updateBindingOperation(boi);
}
try {
bfm.getBindingFactory(ei.getBinding().getBindingId());
} catch (BusException e1) {
continue;
}
try {
Endpoint ep = createEndpoint(ei);
service.getEndpoints().put(ei.getName(), ep);
} catch (EndpointException e) {
throw new ServiceConstructionException(e);
}
}
}
}
use of org.apache.cxf.service.Service in project cxf by apache.
the class ReflectionServiceFactoryBean method create.
@Override
public synchronized Service create() {
reset();
sendEvent(Event.START_CREATE);
initializeServiceConfigurations();
initializeServiceModel();
initializeDefaultInterceptors();
if (invoker != null) {
getService().setInvoker(getInvoker());
} else {
getService().setInvoker(createInvoker());
}
if (getExecutor() != null) {
getService().setExecutor(getExecutor());
}
if (getDataBinding() != null) {
getService().setDataBinding(getDataBinding());
}
getService().put(MethodDispatcher.class.getName(), getMethodDispatcher());
createEndpoints();
fillInSchemaCrossreferences();
Service serv = getService();
sendEvent(Event.END_CREATE, serv);
return serv;
}
Aggregations