Search in sources :

Example 11 with SequenceAcknowledgement

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

the class RMTxStoreTestBase method verifyDestinationSequence.

private void verifyDestinationSequence(String s, DestinationSequence seq) {
    Identifier sid = seq.getIdentifier();
    assertNotNull(sid);
    assertEquals(s, sid.getValue());
    if ("sequence1".equals(s)) {
        assertEquals(0, seq.getLastMessageNumber());
        SequenceAcknowledgement sa = seq.getAcknowledgment();
        assertNotNull(sa);
        verifyAcknowledgementRanges(sa.getAcknowledgementRange(), new long[] { 1, 1 });
        assertEquals(ProtocolVariation.RM10WSA200408, seq.getProtocol());
    } else if ("sequence2".equals(s)) {
        assertEquals(10, seq.getLastMessageNumber());
        SequenceAcknowledgement sa = seq.getAcknowledgment();
        assertNotNull(sa);
        verifyAcknowledgementRanges(sa.getAcknowledgementRange(), new long[] { 1, 1, 3, 10 });
        assertEquals(ProtocolVariation.RM11WSA200508, seq.getProtocol());
    }
}
Also used : Identifier(org.apache.cxf.ws.rm.v200702.Identifier) SequenceAcknowledgement(org.apache.cxf.ws.rm.v200702.SequenceAcknowledgement)

Example 12 with SequenceAcknowledgement

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

the class RMSoapInInterceptorTest method testDecodeAcknowledgements2.

@Test
public void testDecodeAcknowledgements2() throws XMLStreamException {
    SoapMessage message = setUpInboundMessage("resources/Acknowledgment2.xml");
    RMSoapInInterceptor codec = new RMSoapInInterceptor();
    codec.handleMessage(message);
    RMProperties rmps = RMContextUtils.retrieveRMProperties(message, false);
    Collection<SequenceAcknowledgement> acks = rmps.getAcks();
    assertNotNull(acks);
    assertEquals(1, acks.size());
    SequenceAcknowledgement ack = acks.iterator().next();
    assertNotNull(ack);
    assertEquals(1, ack.getAcknowledgementRange().size());
    AcknowledgementRange r1 = ack.getAcknowledgementRange().get(0);
    verifyRange(r1, 1, 3);
    assertNull(rmps.getSequence());
    assertNull(rmps.getAcksRequested());
}
Also used : SequenceAcknowledgement(org.apache.cxf.ws.rm.v200702.SequenceAcknowledgement) AcknowledgementRange(org.apache.cxf.ws.rm.v200702.SequenceAcknowledgement.AcknowledgementRange) RMProperties(org.apache.cxf.ws.rm.RMProperties) SoapMessage(org.apache.cxf.binding.soap.SoapMessage) Test(org.junit.Test)

Example 13 with SequenceAcknowledgement

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

the class RMSoapInInterceptorTest method testDecodeAcknowledgements.

@Test
public void testDecodeAcknowledgements() throws XMLStreamException {
    SoapMessage message = setUpInboundMessage("resources/Acknowledgment.xml");
    RMSoapInInterceptor codec = new RMSoapInInterceptor();
    codec.handleMessage(message);
    RMProperties rmps = RMContextUtils.retrieveRMProperties(message, false);
    Collection<SequenceAcknowledgement> acks = rmps.getAcks();
    assertNotNull(acks);
    assertEquals(1, acks.size());
    SequenceAcknowledgement ack = acks.iterator().next();
    assertNotNull(ack);
    assertEquals(ack.getIdentifier().getValue(), SEQ_IDENTIFIER);
    assertEquals(2, ack.getAcknowledgementRange().size());
    AcknowledgementRange r1 = ack.getAcknowledgementRange().get(0);
    AcknowledgementRange r2 = ack.getAcknowledgementRange().get(1);
    verifyRange(r1, 1, 1);
    verifyRange(r2, 3, 3);
    assertNull(rmps.getSequence());
    assertNull(rmps.getAcksRequested());
}
Also used : SequenceAcknowledgement(org.apache.cxf.ws.rm.v200702.SequenceAcknowledgement) AcknowledgementRange(org.apache.cxf.ws.rm.v200702.SequenceAcknowledgement.AcknowledgementRange) RMProperties(org.apache.cxf.ws.rm.RMProperties) SoapMessage(org.apache.cxf.binding.soap.SoapMessage) Test(org.junit.Test)

Example 14 with SequenceAcknowledgement

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

the class RMSoapOutInterceptorTest method testEncode.

@Test
public void testEncode() throws Exception {
    RMSoapOutInterceptor codec = new RMSoapOutInterceptor();
    setUpOutbound();
    SoapMessage message = setupOutboundMessage();
    // no RM headers
    codec.handleMessage(message);
    verifyHeaders(message, new String[] {});
    // one sequence header
    message = setupOutboundMessage();
    RMProperties rmps = RMContextUtils.retrieveRMProperties(message, true);
    rmps.setSequence(s1);
    codec.encode(message);
    verifyHeaders(message, new String[] { RMConstants.SEQUENCE_NAME });
    // one acknowledgment header
    message = setupOutboundMessage();
    rmps = RMContextUtils.retrieveRMProperties(message, true);
    Collection<SequenceAcknowledgement> acks = new ArrayList<>();
    acks.add(ack1);
    rmps.setAcks(acks);
    codec.encode(message);
    verifyHeaders(message, new String[] { RMConstants.SEQUENCE_ACK_NAME });
    // two acknowledgment headers
    message = setupOutboundMessage();
    rmps = RMContextUtils.retrieveRMProperties(message, true);
    acks.add(ack2);
    rmps.setAcks(acks);
    codec.encode(message);
    verifyHeaders(message, new String[] { RMConstants.SEQUENCE_ACK_NAME, RMConstants.SEQUENCE_ACK_NAME });
    // one ack requested header
    message = setupOutboundMessage();
    rmps = RMContextUtils.retrieveRMProperties(message, true);
    Collection<AckRequestedType> requested = new ArrayList<>();
    requested.add(ar1);
    rmps.setAcksRequested(requested);
    codec.encode(message);
    verifyHeaders(message, new String[] { RMConstants.ACK_REQUESTED_NAME });
    // two ack requested headers
    message = setupOutboundMessage();
    rmps = RMContextUtils.retrieveRMProperties(message, true);
    requested.add(ar2);
    rmps.setAcksRequested(requested);
    codec.encode(message);
    verifyHeaders(message, new String[] { RMConstants.ACK_REQUESTED_NAME, RMConstants.ACK_REQUESTED_NAME });
}
Also used : ArrayList(java.util.ArrayList) AckRequestedType(org.apache.cxf.ws.rm.v200702.AckRequestedType) SequenceAcknowledgement(org.apache.cxf.ws.rm.v200702.SequenceAcknowledgement) RMProperties(org.apache.cxf.ws.rm.RMProperties) SoapMessage(org.apache.cxf.binding.soap.SoapMessage) Test(org.junit.Test)

Example 15 with SequenceAcknowledgement

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

the class SoapFaultFactoryTest method createSoap12FaultWithAcknowledgementDetail.

@Test
public void createSoap12FaultWithAcknowledgementDetail() {
    SoapBinding sb = control.createMock(SoapBinding.class);
    EasyMock.expect(sb.getSoapVersion()).andReturn(Soap12.getInstance());
    SequenceAcknowledgement ack = new SequenceAcknowledgement();
    Identifier id = new Identifier();
    id.setValue("sid");
    ack.setIdentifier(id);
    SequenceAcknowledgement.AcknowledgementRange range = new SequenceAcknowledgement.AcknowledgementRange();
    range.setLower(new Long(1));
    range.setUpper(new Long(10));
    ack.getAcknowledgementRange().add(range);
    setupSequenceFault(true, RM10Constants.INVALID_ACKNOWLEDGMENT_FAULT_QNAME, ack);
    control.replay();
    SoapFaultFactory factory = new SoapFaultFactory(sb);
    SoapFault fault = (SoapFault) factory.createFault(sf, createInboundMessage());
    assertEquals("reason", fault.getReason());
    assertEquals(Soap12.getInstance().getSender(), fault.getFaultCode());
    assertEquals(RM10Constants.INVALID_ACKNOWLEDGMENT_FAULT_QNAME, fault.getSubCode());
    Element elem = fault.getDetail();
    assertEquals(RM10Constants.NAMESPACE_URI, elem.getNamespaceURI());
    assertEquals("SequenceAcknowledgement", elem.getLocalName());
    control.verify();
}
Also used : SoapFault(org.apache.cxf.binding.soap.SoapFault) Identifier(org.apache.cxf.ws.rm.v200702.Identifier) Element(org.w3c.dom.Element) SequenceAcknowledgement(org.apache.cxf.ws.rm.v200702.SequenceAcknowledgement) SoapBinding(org.apache.cxf.binding.soap.SoapBinding) Test(org.junit.Test)

Aggregations

SequenceAcknowledgement (org.apache.cxf.ws.rm.v200702.SequenceAcknowledgement)33 Test (org.junit.Test)11 Identifier (org.apache.cxf.ws.rm.v200702.Identifier)10 ArrayList (java.util.ArrayList)6 AckRequestedType (org.apache.cxf.ws.rm.v200702.AckRequestedType)6 AcknowledgementRange (org.apache.cxf.ws.rm.v200702.SequenceAcknowledgement.AcknowledgementRange)5 SequenceType (org.apache.cxf.ws.rm.v200702.SequenceType)5 Element (org.w3c.dom.Element)5 ProtocolVariation (org.apache.cxf.ws.rm.ProtocolVariation)4 CloseSequenceType (org.apache.cxf.ws.rm.v200702.CloseSequenceType)4 CreateSequenceType (org.apache.cxf.ws.rm.v200702.CreateSequenceType)4 TerminateSequenceType (org.apache.cxf.ws.rm.v200702.TerminateSequenceType)4 InputStream (java.io.InputStream)3 Connection (java.sql.Connection)3 JAXBElement (javax.xml.bind.JAXBElement)3 QName (javax.xml.namespace.QName)3 SoapHeader (org.apache.cxf.binding.soap.SoapHeader)3 SoapMessage (org.apache.cxf.binding.soap.SoapMessage)3 AddressingProperties (org.apache.cxf.ws.addressing.AddressingProperties)3 EndpointReferenceType (org.apache.cxf.ws.addressing.EndpointReferenceType)3