use of org.apache.cxf.service.model.ServiceInfo in project cxf by apache.
the class JMSEndpointWSDLUtil method getWSDLExtensor.
public static <T> T getWSDLExtensor(EndpointInfo ei, Class<T> cls) {
ServiceInfo si = ei.getService();
BindingInfo bi = ei.getBinding();
Object o = ei.getExtensor(cls);
if (o == null && si != null) {
o = si.getExtensor(cls);
}
if (o == null && bi != null) {
o = bi.getExtensor(cls);
}
if (o == null) {
return null;
}
if (cls.isInstance(o)) {
return cls.cast(o);
}
return null;
}
use of org.apache.cxf.service.model.ServiceInfo in project cxf by apache.
the class RMManagerTest method testRecoverReliableClientEndpointWithAttachment.
@Test
public void testRecoverReliableClientEndpointWithAttachment() throws NoSuchMethodException, IOException {
Method method = RMManager.class.getDeclaredMethod("createReliableEndpoint", new Class[] { Endpoint.class });
manager = control.createMock(RMManager.class, new Method[] { method });
manager.setReliableEndpointsMap(new HashMap<Endpoint, RMEndpoint>());
Endpoint endpoint = control.createMock(Endpoint.class);
EndpointInfo ei = control.createMock(EndpointInfo.class);
ServiceInfo si = control.createMock(ServiceInfo.class);
BindingInfo bi = control.createMock(BindingInfo.class);
InterfaceInfo ii = control.createMock(InterfaceInfo.class);
setUpEndpointForRecovery(endpoint, ei, si, bi, ii);
Conduit conduit = control.createMock(Conduit.class);
SourceSequence ss = control.createMock(SourceSequence.class);
DestinationSequence ds = control.createMock(DestinationSequence.class);
RMMessage m1 = new RMMessage();
InputStream fis = getClass().getResourceAsStream("persistence/SerializedRMMessage.txt");
CachedOutputStream cos = new CachedOutputStream();
IOUtils.copyAndCloseInput(fis, cos);
cos.flush();
m1.setContent(cos);
m1.setTo("toAddress");
m1.setMessageNumber(Long.valueOf(10));
m1.setContentType(MULTIPART_TYPE);
Capture<Message> mc = Capture.newInstance();
setUpRecoverReliableEndpointWithAttachment(endpoint, conduit, ss, ds, m1, mc);
control.replay();
manager.recoverReliableEndpoint(endpoint, conduit);
control.verify();
Message msg = mc.getValue();
assertNotNull(msg);
assertNotNull(msg.getExchange());
assertSame(msg, msg.getExchange().getOutMessage());
CachedOutputStream cos1 = (CachedOutputStream) msg.get(RMMessageConstants.SAVED_CONTENT);
assertStartsWith(cos1.getInputStream(), "<soap:Envelope");
assertEquals(1, msg.getAttachments().size());
}
use of org.apache.cxf.service.model.ServiceInfo in project cxf by apache.
the class RMManagerTest method testRecoverReliableClientEndpoint.
@Test
public void testRecoverReliableClientEndpoint() throws NoSuchMethodException, IOException {
Method method = RMManager.class.getDeclaredMethod("createReliableEndpoint", new Class[] { Endpoint.class });
manager = control.createMock(RMManager.class, new Method[] { method });
manager.setReliableEndpointsMap(new HashMap<Endpoint, RMEndpoint>());
Endpoint endpoint = control.createMock(Endpoint.class);
EndpointInfo ei = control.createMock(EndpointInfo.class);
ServiceInfo si = control.createMock(ServiceInfo.class);
BindingInfo bi = control.createMock(BindingInfo.class);
InterfaceInfo ii = control.createMock(InterfaceInfo.class);
setUpEndpointForRecovery(endpoint, ei, si, bi, ii);
Conduit conduit = control.createMock(Conduit.class);
setUpRecoverReliableEndpoint(endpoint, conduit, null, null, null);
control.replay();
manager.recoverReliableEndpoint(endpoint, conduit);
control.verify();
control.reset();
setUpEndpointForRecovery(endpoint, ei, si, bi, ii);
SourceSequence ss = control.createMock(SourceSequence.class);
DestinationSequence ds = control.createMock(DestinationSequence.class);
setUpRecoverReliableEndpoint(endpoint, conduit, ss, ds, null);
control.replay();
manager.recoverReliableEndpoint(endpoint, conduit);
control.verify();
control.reset();
setUpEndpointForRecovery(endpoint, ei, si, bi, ii);
RMMessage m = control.createMock(RMMessage.class);
setUpRecoverReliableEndpoint(endpoint, conduit, ss, ds, m);
control.replay();
manager.recoverReliableEndpoint(endpoint, conduit);
control.verify();
}
use of org.apache.cxf.service.model.ServiceInfo in project cxf by apache.
the class RMUtilsTest method testGetName.
@Test
public void testGetName() {
// no bus given
Endpoint e = control.createMock(Endpoint.class);
EndpointInfo ei = control.createMock(EndpointInfo.class);
EasyMock.expect(e.getEndpointInfo()).andReturn(ei).times(2);
QName eqn = new QName("ns2", "endpoint");
EasyMock.expect(ei.getName()).andReturn(eqn);
ServiceInfo si = control.createMock(ServiceInfo.class);
EasyMock.expect(ei.getService()).andReturn(si);
QName sqn = new QName("ns1", "service");
EasyMock.expect(si.getName()).andReturn(sqn);
control.replay();
assertEquals("{ns1}service.{ns2}endpoint@" + Bus.DEFAULT_BUS_ID, RMUtils.getEndpointIdentifier(e));
// a named bus
control.reset();
EasyMock.expect(e.getEndpointInfo()).andReturn(ei).times(2);
EasyMock.expect(ei.getName()).andReturn(eqn);
EasyMock.expect(ei.getService()).andReturn(si);
EasyMock.expect(si.getName()).andReturn(sqn);
Bus b = control.createMock(Bus.class);
EasyMock.expect(b.getId()).andReturn("mybus");
control.replay();
assertEquals("{ns1}service.{ns2}endpoint@mybus", RMUtils.getEndpointIdentifier(e, b));
// this test makes sure that an automatically generated id will be
// mapped to the static default bus name "cxf".
// System.out.println("bus: " + BusFactory.getThreadDefaultBus(false));
control.reset();
EasyMock.expect(e.getEndpointInfo()).andReturn(ei).times(2);
EasyMock.expect(ei.getName()).andReturn(eqn);
EasyMock.expect(ei.getService()).andReturn(si);
EasyMock.expect(si.getName()).andReturn(sqn);
control.replay();
Bus bus = BusFactory.getDefaultBus();
assertEquals("{ns1}service.{ns2}endpoint@" + Bus.DEFAULT_BUS_ID, RMUtils.getEndpointIdentifier(e, bus));
bus.shutdown(true);
// a generated bundle artifact bus
control.reset();
EasyMock.expect(e.getEndpointInfo()).andReturn(ei).times(2);
EasyMock.expect(ei.getName()).andReturn(eqn);
EasyMock.expect(ei.getService()).andReturn(si);
EasyMock.expect(si.getName()).andReturn(sqn);
EasyMock.expect(b.getId()).andReturn("mybus-" + Bus.DEFAULT_BUS_ID + "12345");
control.replay();
assertEquals("{ns1}service.{ns2}endpoint@mybus-" + Bus.DEFAULT_BUS_ID, RMUtils.getEndpointIdentifier(e, b));
// look like a generated bundle artifact bus but not
control.reset();
EasyMock.expect(e.getEndpointInfo()).andReturn(ei).times(2);
EasyMock.expect(ei.getName()).andReturn(eqn);
EasyMock.expect(ei.getService()).andReturn(si);
EasyMock.expect(si.getName()).andReturn(sqn);
EasyMock.expect(b.getId()).andReturn("mybus." + Bus.DEFAULT_BUS_ID + ".foo");
control.replay();
assertEquals("{ns1}service.{ns2}endpoint@mybus." + Bus.DEFAULT_BUS_ID + ".foo", RMUtils.getEndpointIdentifier(e, b));
}
use of org.apache.cxf.service.model.ServiceInfo 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