Search in sources :

Example 66 with ServiceInfo

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;
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) BindingInfo(org.apache.cxf.service.model.BindingInfo)

Example 67 with ServiceInfo

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());
}
Also used : RMMessage(org.apache.cxf.ws.rm.persistence.RMMessage) Message(org.apache.cxf.message.Message) RMMessage(org.apache.cxf.ws.rm.persistence.RMMessage) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) Method(java.lang.reflect.Method) CachedOutputStream(org.apache.cxf.io.CachedOutputStream) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) Endpoint(org.apache.cxf.endpoint.Endpoint) Conduit(org.apache.cxf.transport.Conduit) BindingInfo(org.apache.cxf.service.model.BindingInfo) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo) Test(org.junit.Test)

Example 68 with ServiceInfo

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();
}
Also used : RMMessage(org.apache.cxf.ws.rm.persistence.RMMessage) Method(java.lang.reflect.Method) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) Endpoint(org.apache.cxf.endpoint.Endpoint) Conduit(org.apache.cxf.transport.Conduit) BindingInfo(org.apache.cxf.service.model.BindingInfo) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo) Test(org.junit.Test)

Example 69 with ServiceInfo

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));
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) Bus(org.apache.cxf.Bus) Endpoint(org.apache.cxf.endpoint.Endpoint) QName(javax.xml.namespace.QName) Test(org.junit.Test)

Example 70 with ServiceInfo

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);
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) OperationInfo(org.apache.cxf.service.model.OperationInfo) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) EndpointReferenceType(org.apache.cxf.ws.addressing.EndpointReferenceType) Endpoint(org.apache.cxf.endpoint.Endpoint) AttributedURIType(org.apache.cxf.ws.addressing.AttributedURIType) Method(java.lang.reflect.Method) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo) Test(org.junit.Test)

Aggregations

ServiceInfo (org.apache.cxf.service.model.ServiceInfo)195 QName (javax.xml.namespace.QName)89 Test (org.junit.Test)76 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)63 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)47 BindingInfo (org.apache.cxf.service.model.BindingInfo)43 OperationInfo (org.apache.cxf.service.model.OperationInfo)37 InterfaceInfo (org.apache.cxf.service.model.InterfaceInfo)36 Service (org.apache.cxf.service.Service)33 Endpoint (org.apache.cxf.endpoint.Endpoint)31 MessagePartInfo (org.apache.cxf.service.model.MessagePartInfo)29 File (java.io.File)28 ArrayList (java.util.ArrayList)27 Bus (org.apache.cxf.Bus)26 InputStream (java.io.InputStream)23 Definition (javax.wsdl.Definition)20 Method (java.lang.reflect.Method)16 SchemaCollection (org.apache.cxf.common.xmlschema.SchemaCollection)15 HTTPTransportFactory (org.apache.cxf.transport.http.HTTPTransportFactory)15 IOException (java.io.IOException)12