Search in sources :

Example 11 with CreateSequenceResponseType

use of org.apache.cxf.ws.rm.v200702.CreateSequenceResponseType in project cxf by apache.

the class ProxyTest method testCreateSequence.

@SuppressWarnings("unchecked")
private void testCreateSequence(boolean isServer) throws NoSuchMethodException, RMException {
    Method m = Proxy.class.getDeclaredMethod("invoke", new Class[] { OperationInfo.class, ProtocolVariation.class, Object[].class, Map.class, Exchange.class });
    Proxy proxy = EasyMock.createMockBuilder(Proxy.class).addMockedMethod(m).createMock(control);
    proxy.setReliableEndpoint(rme);
    RMManager manager = control.createMock(RMManager.class);
    EasyMock.expect(rme.getManager()).andReturn(manager).anyTimes();
    SourcePolicyType sp = control.createMock(SourcePolicyType.class);
    EasyMock.expect(manager.getSourcePolicy()).andReturn(sp).anyTimes();
    EasyMock.expect(sp.getAcksTo()).andReturn(null).anyTimes();
    Duration d = DatatypeFactory.createDuration("PT12H");
    EasyMock.expect(sp.getSequenceExpiration()).andReturn(d).anyTimes();
    EasyMock.expect(sp.isIncludeOffer()).andReturn(Boolean.TRUE).anyTimes();
    Duration dOffered = DatatypeFactory.createDuration("PT24H");
    EasyMock.expect(sp.getOfferedSequenceExpiration()).andReturn(dOffered).anyTimes();
    Source source = control.createMock(Source.class);
    EasyMock.expect(rme.getSource()).andReturn(source).anyTimes();
    Identifier offeredId = control.createMock(Identifier.class);
    EasyMock.expect(source.generateSequenceIdentifier()).andReturn(offeredId).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);
    org.apache.cxf.ws.rm.v200502.CreateSequenceResponseType csr = null;
    if (isServer) {
        EasyMock.expect(ii.getOperation(RM10Constants.CREATE_SEQUENCE_ONEWAY_QNAME)).andReturn(oi).anyTimes();
        Endpoint ae = control.createMock(Endpoint.class);
        EasyMock.expect(rme.getApplicationEndpoint()).andReturn(ae).anyTimes();
        EasyMock.expect(ae.getExecutor()).andReturn(SynchronousExecutor.getInstance()).anyTimes();
    } else {
        EasyMock.expect(ii.getOperation(RM10Constants.CREATE_SEQUENCE_QNAME)).andReturn(oi).anyTimes();
        csr = new org.apache.cxf.ws.rm.v200502.CreateSequenceResponseType();
    }
    ExchangeImpl exchange = new ExchangeImpl();
    EasyMock.expect(proxy.invoke(EasyMock.same(oi), EasyMock.isA(ProtocolVariation.class), EasyMock.isA(Object[].class), EasyMock.isA(Map.class), EasyMock.isA(Exchange.class))).andReturn(csr).anyTimes();
    EndpointReferenceType defaultAcksTo = control.createMock(EndpointReferenceType.class);
    AttributedURIType aut = control.createMock(AttributedURIType.class);
    EasyMock.expect(aut.getValue()).andReturn("here").anyTimes();
    EasyMock.expect(defaultAcksTo.getAddress()).andReturn(aut).anyTimes();
    RelatesToType relatesTo = control.createMock(RelatesToType.class);
    control.replay();
    Map<String, Object> context = new HashMap<>();
    if (isServer) {
        assertNull(proxy.createSequence(defaultAcksTo, relatesTo, isServer, ProtocolVariation.RM10WSA200408, exchange, context));
    } else {
        assertNotNull(proxy.createSequence(defaultAcksTo, relatesTo, isServer, ProtocolVariation.RM10WSA200408, exchange, context));
    }
}
Also used : BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) OperationInfo(org.apache.cxf.service.model.OperationInfo) EndpointReferenceType(org.apache.cxf.ws.addressing.EndpointReferenceType) HashMap(java.util.HashMap) AttributedURIType(org.apache.cxf.ws.addressing.AttributedURIType) Duration(javax.xml.datatype.Duration) Method(java.lang.reflect.Method) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) RelatesToType(org.apache.cxf.ws.addressing.RelatesToType) Identifier(org.apache.cxf.ws.rm.v200702.Identifier) Endpoint(org.apache.cxf.endpoint.Endpoint) SourcePolicyType(org.apache.cxf.ws.rm.manager.SourcePolicyType) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo) ExchangeImpl(org.apache.cxf.message.ExchangeImpl)

Example 12 with CreateSequenceResponseType

use of org.apache.cxf.ws.rm.v200702.CreateSequenceResponseType in project cxf by apache.

the class RMInInterceptorTest method testHandleCreateSequenceOnClient.

@Test
public void testHandleCreateSequenceOnClient() throws SequenceFault, RMException {
    interceptor = new RMInInterceptor();
    Message message = setupInboundMessage(RM10Constants.CREATE_SEQUENCE_ACTION, false);
    rme.receivedControlMessage();
    EasyMock.expectLastCall();
    Servant servant = control.createMock(Servant.class);
    EasyMock.expect(rme.getServant()).andReturn(servant);
    CreateSequenceResponseType csr = control.createMock(CreateSequenceResponseType.class);
    EasyMock.expect(servant.createSequence(message)).andReturn(csr);
    Proxy proxy = control.createMock(Proxy.class);
    EasyMock.expect(rme.getProxy()).andReturn(proxy);
    proxy.createSequenceResponse(csr, ProtocolVariation.RM10WSA200408);
    EasyMock.expectLastCall();
    control.replay();
    interceptor.handle(message);
}
Also used : Message(org.apache.cxf.message.Message) CreateSequenceResponseType(org.apache.cxf.ws.rm.v200702.CreateSequenceResponseType) Test(org.junit.Test)

Example 13 with CreateSequenceResponseType

use of org.apache.cxf.ws.rm.v200702.CreateSequenceResponseType in project cxf by apache.

the class ServantTest method verifyCreateSequenceExpiresSetAtSource.

private void verifyCreateSequenceExpiresSetAtSource(Servant servant, RMManager manager) throws SequenceFault {
    DestinationPolicyType dp = RMMANGER_FACTORY.createDestinationPolicyType();
    AcksPolicyType ap = RMMANGER_FACTORY.createAcksPolicyType();
    dp.setAcksPolicy(ap);
    manager.setDestinationPolicy(dp);
    Expires expires = new Expires();
    expires.setValue(DURATION_SHORT);
    Message message = createTestCreateSequenceMessage(expires, null);
    CreateSequenceResponseType csr = (CreateSequenceResponseType) servant.createSequence(message);
    Expires expires2 = csr.getExpires();
    assertNotNull(expires2);
    assertEquals(DURATION_SHORT, expires2.getValue());
}
Also used : AcksPolicyType(org.apache.cxf.ws.rm.manager.AcksPolicyType) Message(org.apache.cxf.message.Message) DestinationPolicyType(org.apache.cxf.ws.rm.manager.DestinationPolicyType) Expires(org.apache.cxf.ws.rm.v200502.Expires) CreateSequenceResponseType(org.apache.cxf.ws.rm.v200502.CreateSequenceResponseType)

Example 14 with CreateSequenceResponseType

use of org.apache.cxf.ws.rm.v200702.CreateSequenceResponseType in project cxf by apache.

the class ServantTest method verifyCreateSequenceExpiresSetAtBoth.

private void verifyCreateSequenceExpiresSetAtBoth(Servant servant, RMManager manager) throws SequenceFault {
    DestinationPolicyType dp = RMMANGER_FACTORY.createDestinationPolicyType();
    AcksPolicyType ap = RMMANGER_FACTORY.createAcksPolicyType();
    dp.setAcksPolicy(ap);
    dp.setSequenceExpiration(DURATION_SHORT);
    manager.setDestinationPolicy(dp);
    Expires expires = new Expires();
    expires.setValue(DURATION_VERY_SHORT);
    Message message = createTestCreateSequenceMessage(expires, null);
    CreateSequenceResponseType csr = (CreateSequenceResponseType) servant.createSequence(message);
    Expires expires2 = csr.getExpires();
    assertNotNull(expires2);
    assertEquals(DURATION_VERY_SHORT, expires2.getValue());
}
Also used : AcksPolicyType(org.apache.cxf.ws.rm.manager.AcksPolicyType) Message(org.apache.cxf.message.Message) DestinationPolicyType(org.apache.cxf.ws.rm.manager.DestinationPolicyType) Expires(org.apache.cxf.ws.rm.v200502.Expires) CreateSequenceResponseType(org.apache.cxf.ws.rm.v200502.CreateSequenceResponseType)

Aggregations

Message (org.apache.cxf.message.Message)8 CreateSequenceResponseType (org.apache.cxf.ws.rm.v200702.CreateSequenceResponseType)7 DestinationPolicyType (org.apache.cxf.ws.rm.manager.DestinationPolicyType)5 EndpointReferenceType (org.apache.cxf.ws.addressing.EndpointReferenceType)4 AcksPolicyType (org.apache.cxf.ws.rm.manager.AcksPolicyType)4 CreateSequenceResponseType (org.apache.cxf.ws.rm.v200502.CreateSequenceResponseType)4 Expires (org.apache.cxf.ws.rm.v200502.Expires)4 Duration (javax.xml.datatype.Duration)3 Endpoint (org.apache.cxf.endpoint.Endpoint)3 OperationInfo (org.apache.cxf.service.model.OperationInfo)3 AddressingProperties (org.apache.cxf.ws.addressing.AddressingProperties)3 Identifier (org.apache.cxf.ws.rm.v200702.Identifier)3 Method (java.lang.reflect.Method)2 HashMap (java.util.HashMap)2 Exchange (org.apache.cxf.message.Exchange)2 ExchangeImpl (org.apache.cxf.message.ExchangeImpl)2 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)2 InterfaceInfo (org.apache.cxf.service.model.InterfaceInfo)2 AttributedURIType (org.apache.cxf.ws.addressing.AttributedURIType)2 RelatesToType (org.apache.cxf.ws.addressing.RelatesToType)2