Search in sources :

Example 6 with SequenceAcknowledgement

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

the class VersionTransformer method convert.

/**
 * Convert 200502 wsrm:SequenceAcknowledgement with 200508 WS-Addressing namespace to internal form.
 *
 * @param exposed (non-<code>null</code>)
 * @return converted
 */
public static SequenceAcknowledgement convert(org.apache.cxf.ws.rm.v200502wsa15.SequenceAcknowledgement exposed) {
    SequenceAcknowledgement internal = new SequenceAcknowledgement();
    internal.setIdentifier(convert(exposed.getIdentifier()));
    List<SequenceAcknowledgement.AcknowledgementRange> internalRanges = internal.getAcknowledgementRange();
    for (org.apache.cxf.ws.rm.v200502wsa15.SequenceAcknowledgement.AcknowledgementRange range : exposed.getAcknowledgementRange()) {
        SequenceAcknowledgement.AcknowledgementRange internalRange = new SequenceAcknowledgement.AcknowledgementRange();
        internalRange.setLower(range.getLower());
        internalRange.setUpper(range.getUpper());
        internalRanges.add(internalRange);
        putAll(range.getOtherAttributes(), internalRange.getOtherAttributes());
    }
    addAll(exposed.getAny(), internal.getAny());
    putAll(exposed.getOtherAttributes(), internal.getOtherAttributes());
    return internal;
}
Also used : SequenceAcknowledgement(org.apache.cxf.ws.rm.v200702.SequenceAcknowledgement)

Example 7 with SequenceAcknowledgement

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

the class PersistenceUtils method deserialiseAcknowledgment.

public SequenceAcknowledgement deserialiseAcknowledgment(InputStream is) {
    Object obj = null;
    XMLStreamReader reader = StaxUtils.createXMLStreamReader(is);
    try {
        obj = getContext().createUnmarshaller().unmarshal(reader);
        if (obj instanceof JAXBElement<?>) {
            JAXBElement<?> el = (JAXBElement<?>) obj;
            obj = el.getValue();
        }
    } catch (JAXBException ex) {
        throw new RMStoreException(ex);
    } finally {
        try {
            StaxUtils.close(reader);
            is.close();
        } catch (Throwable t) {
        // ignore, just cleaning up
        }
    }
    return (SequenceAcknowledgement) obj;
}
Also used : XMLStreamReader(javax.xml.stream.XMLStreamReader) JAXBException(javax.xml.bind.JAXBException) JAXBElement(javax.xml.bind.JAXBElement) SequenceAcknowledgement(org.apache.cxf.ws.rm.v200702.SequenceAcknowledgement)

Example 8 with SequenceAcknowledgement

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

the class PersistenceUtilsTest method testSerialiseDeserialiseAcknowledgement.

@Test
public void testSerialiseDeserialiseAcknowledgement() {
    SequenceAcknowledgement ack = new SequenceAcknowledgement();
    AcknowledgementRange range = new AcknowledgementRange();
    range.setLower(new Long(1));
    range.setUpper(new Long(10));
    ack.getAcknowledgementRange().add(range);
    PersistenceUtils utils = PersistenceUtils.getInstance();
    InputStream is = utils.serialiseAcknowledgment(ack);
    SequenceAcknowledgement refAck = utils.deserialiseAcknowledgment(is);
    assertEquals(refAck.getAcknowledgementRange().size(), refAck.getAcknowledgementRange().size());
    AcknowledgementRange refRange = refAck.getAcknowledgementRange().get(0);
    assertEquals(range.getLower(), refRange.getLower());
    assertEquals(range.getUpper(), refRange.getUpper());
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) SequenceAcknowledgement(org.apache.cxf.ws.rm.v200702.SequenceAcknowledgement) AcknowledgementRange(org.apache.cxf.ws.rm.v200702.SequenceAcknowledgement.AcknowledgementRange) Test(org.junit.Test)

Example 9 with SequenceAcknowledgement

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

the class RMTxStoreTestBase method setUpOnce.

public static void setUpOnce() {
    ack1 = new SequenceAcknowledgement();
    SequenceAcknowledgement.AcknowledgementRange range = new SequenceAcknowledgement.AcknowledgementRange();
    range.setLower(ONE);
    range.setUpper(ONE);
    ack1.getAcknowledgementRange().add(range);
    ack2 = new SequenceAcknowledgement();
    range = new SequenceAcknowledgement.AcknowledgementRange();
    range.setLower(ONE);
    range.setUpper(ONE);
    ack2.getAcknowledgementRange().add(range);
    range = new SequenceAcknowledgement.AcknowledgementRange();
    range.setLower(new Long(3));
    range.setUpper(TEN);
    ack2.getAcknowledgementRange().add(range);
}
Also used : SequenceAcknowledgement(org.apache.cxf.ws.rm.v200702.SequenceAcknowledgement)

Example 10 with SequenceAcknowledgement

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

the class RMTxStoreTestBase method setupDestinationSequence.

private Identifier setupDestinationSequence(String s) throws IOException, SQLException {
    DestinationSequence seq = control.createMock(DestinationSequence.class);
    Identifier sid = new Identifier();
    sid.setValue(s);
    EndpointReferenceType epr = RMUtils.createAnonymousReference();
    SequenceAcknowledgement ack = ack1;
    Long lmn = ZERO;
    ProtocolVariation pv = ProtocolVariation.RM10WSA200408;
    if ("sequence2".equals(s)) {
        ack = ack2;
        lmn = TEN;
        pv = ProtocolVariation.RM11WSA200508;
    }
    EasyMock.expect(seq.getIdentifier()).andReturn(sid);
    EasyMock.expect(seq.getAcksTo()).andReturn(epr);
    EasyMock.expect(seq.getEndpointIdentifier()).andReturn(SERVER_ENDPOINT_ID);
    EasyMock.expect(seq.getLastMessageNumber()).andReturn(lmn);
    EasyMock.expect(seq.getAcknowledgment()).andReturn(ack);
    EasyMock.expect(seq.getIdentifier()).andReturn(sid);
    EasyMock.expect(seq.getProtocol()).andReturn(pv);
    control.replay();
    store.createDestinationSequence(seq);
    Connection con = getConnection();
    try {
        store.beginTransaction();
        store.updateDestinationSequence(con, seq);
        store.commit(con);
    } finally {
        releaseConnection(con);
    }
    control.reset();
    return sid;
}
Also used : DestinationSequence(org.apache.cxf.ws.rm.DestinationSequence) Identifier(org.apache.cxf.ws.rm.v200702.Identifier) EndpointReferenceType(org.apache.cxf.ws.addressing.EndpointReferenceType) Connection(java.sql.Connection) SequenceAcknowledgement(org.apache.cxf.ws.rm.v200702.SequenceAcknowledgement) ProtocolVariation(org.apache.cxf.ws.rm.ProtocolVariation)

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