Search in sources :

Example 26 with Identifier

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

the class VersionTransformer method convert.

/**
 * Convert 200502 wsrm:Identifier with 200508 WS-Addressing namespace to internal form.
 *
 * @param exposed (may be <code>null</code>)
 * @return converted (<code>null</code> if exposed is <code>null</code>)
 */
public static Identifier convert(org.apache.cxf.ws.rm.v200502wsa15.Identifier exposed) {
    if (exposed == null) {
        return null;
    }
    Identifier internal = new Identifier();
    internal.setValue(exposed.getValue());
    putAll(exposed.getOtherAttributes(), internal.getOtherAttributes());
    return internal;
}
Also used : Identifier(org.apache.cxf.ws.rm.v200702.Identifier)

Example 27 with Identifier

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

the class RMTxStoreTestBase method testCreateSequenceStoreOutboundMessage.

@Test
public void testCreateSequenceStoreOutboundMessage() throws SQLException, IOException {
    Identifier sid1 = null;
    try {
        SourceSequence seq = control.createMock(SourceSequence.class);
        sid1 = new Identifier();
        sid1.setValue("sequence1");
        EasyMock.expect(seq.getIdentifier()).andReturn(sid1);
        EasyMock.expect(seq.getExpires()).andReturn(null);
        EasyMock.expect(seq.getOfferingSequenceIdentifier()).andReturn(null);
        EasyMock.expect(seq.getEndpointIdentifier()).andReturn(CLIENT_ENDPOINT_ID);
        EasyMock.expect(seq.getProtocol()).andReturn(ProtocolVariation.RM10WSA200408);
        control.replay();
        store.createSourceSequence(seq);
        control.reset();
        Collection<SourceSequence> seqs = store.getSourceSequences(CLIENT_ENDPOINT_ID);
        assertEquals(1, seqs.size());
        SourceSequence rseq = seqs.iterator().next();
        assertFalse(rseq.isLastMessage());
        Collection<RMMessage> out = store.getMessages(sid1, true);
        assertEquals(0, out.size());
        // set the last message flag
        EasyMock.expect(seq.getIdentifier()).andReturn(sid1).anyTimes();
        EasyMock.expect(seq.isLastMessage()).andReturn(true);
        setupOutboundMessage(seq, 1L, null);
        out = store.getMessages(sid1, true);
        assertEquals(1, out.size());
        checkRecoveredMessages(out);
        // verify the updated sequence
        seqs = store.getSourceSequences(CLIENT_ENDPOINT_ID);
        assertEquals(1, seqs.size());
        rseq = seqs.iterator().next();
        assertTrue(rseq.isLastMessage());
        // set the last message flag
        EasyMock.expect(seq.getIdentifier()).andReturn(sid1).anyTimes();
        EasyMock.expect(seq.getCurrentMessageNr()).andReturn(2L);
        EasyMock.expect(seq.isLastMessage()).andReturn(true);
        control.replay();
        store.persistOutgoing(seq, null);
        control.reset();
        seqs = store.getSourceSequences(CLIENT_ENDPOINT_ID);
        assertEquals(1, seqs.size());
        rseq = seqs.iterator().next();
        assertEquals(2, rseq.getCurrentMessageNr());
    } finally {
        if (null != sid1) {
            store.removeSourceSequence(sid1);
        }
        Collection<Long> msgNrs = new ArrayList<>();
        msgNrs.add(ONE);
        store.removeMessages(sid1, msgNrs, true);
    }
}
Also used : Identifier(org.apache.cxf.ws.rm.v200702.Identifier) RMMessage(org.apache.cxf.ws.rm.persistence.RMMessage) ArrayList(java.util.ArrayList) SourceSequence(org.apache.cxf.ws.rm.SourceSequence) Test(org.junit.Test)

Example 28 with Identifier

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

the class RMTxStoreTestBase method testGetMessages.

@Test
public void testGetMessages() throws SQLException, IOException {
    Identifier sid1 = new Identifier();
    sid1.setValue("sequence1");
    Identifier sid2 = new Identifier();
    sid2.setValue("sequence2");
    Collection<RMMessage> out = store.getMessages(sid1, true);
    assertEquals(0, out.size());
    Collection<RMMessage> in = store.getMessages(sid1, false);
    assertEquals(0, out.size());
    try {
        setupMessage(sid1, ONE, null, true);
        setupMessage(sid1, ONE, null, false);
        out = store.getMessages(sid1, true);
        assertEquals(1, out.size());
        checkRecoveredMessages(out);
        in = store.getMessages(sid1, false);
        assertEquals(1, in.size());
        checkRecoveredMessages(in);
        setupMessage(sid1, TEN, NON_ANON_ACKS_TO, true);
        setupMessage(sid1, TEN, NON_ANON_ACKS_TO, false);
        out = store.getMessages(sid1, true);
        assertEquals(2, out.size());
        checkRecoveredMessages(out);
        in = store.getMessages(sid1, false);
        assertEquals(2, in.size());
        checkRecoveredMessages(in);
    } finally {
        Collection<Long> msgNrs = new ArrayList<>();
        msgNrs.add(ONE);
        msgNrs.add(TEN);
        store.removeMessages(sid1, msgNrs, true);
        store.removeMessages(sid1, msgNrs, false);
    }
}
Also used : Identifier(org.apache.cxf.ws.rm.v200702.Identifier) RMMessage(org.apache.cxf.ws.rm.persistence.RMMessage) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 29 with Identifier

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

the class RMTxStoreTestBase method testGetDestinationSequences.

@Test
public void testGetDestinationSequences() throws SQLException, IOException {
    Identifier sid1 = null;
    Identifier sid2 = null;
    Collection<DestinationSequence> seqs = store.getDestinationSequences("unknown");
    assertEquals(0, seqs.size());
    try {
        sid1 = setupDestinationSequence("sequence1");
        seqs = store.getDestinationSequences(SERVER_ENDPOINT_ID);
        assertEquals(1, seqs.size());
        checkRecoveredDestinationSequences(seqs);
        sid2 = setupDestinationSequence("sequence2");
        seqs = store.getDestinationSequences(SERVER_ENDPOINT_ID);
        assertEquals(2, seqs.size());
        checkRecoveredDestinationSequences(seqs);
    } finally {
        if (null != sid1) {
            store.removeDestinationSequence(sid1);
        }
        if (null != sid2) {
            store.removeDestinationSequence(sid2);
        }
    }
}
Also used : DestinationSequence(org.apache.cxf.ws.rm.DestinationSequence) Identifier(org.apache.cxf.ws.rm.v200702.Identifier) Test(org.junit.Test)

Example 30 with Identifier

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

the class RMTxStoreTestBase method testGetDestinationSequence.

@Test
public void testGetDestinationSequence() throws SQLException, IOException {
    Identifier sid1 = null;
    Identifier sid2 = null;
    DestinationSequence seq = store.getDestinationSequence(new Identifier());
    assertNull(seq);
    try {
        sid1 = setupDestinationSequence("sequence1");
        seq = store.getDestinationSequence(sid1);
        assertNotNull(seq);
        verifyDestinationSequence("sequence1", seq);
        sid2 = setupDestinationSequence("sequence2");
        seq = store.getDestinationSequence(sid2);
        assertNotNull(seq);
        verifyDestinationSequence("sequence2", seq);
    } finally {
        if (null != sid1) {
            store.removeDestinationSequence(sid1);
        }
        if (null != sid2) {
            store.removeDestinationSequence(sid2);
        }
    }
}
Also used : DestinationSequence(org.apache.cxf.ws.rm.DestinationSequence) Identifier(org.apache.cxf.ws.rm.v200702.Identifier) Test(org.junit.Test)

Aggregations

Identifier (org.apache.cxf.ws.rm.v200702.Identifier)72 Test (org.junit.Test)40 Message (org.apache.cxf.message.Message)14 ArrayList (java.util.ArrayList)13 RMMessage (org.apache.cxf.ws.rm.persistence.RMMessage)13 SequenceAcknowledgement (org.apache.cxf.ws.rm.v200702.SequenceAcknowledgement)13 SourceSequence (org.apache.cxf.ws.rm.SourceSequence)11 Connection (java.sql.Connection)10 AddressingProperties (org.apache.cxf.ws.addressing.AddressingProperties)10 EndpointReferenceType (org.apache.cxf.ws.addressing.EndpointReferenceType)9 SQLException (java.sql.SQLException)8 DestinationSequence (org.apache.cxf.ws.rm.DestinationSequence)8 Date (java.util.Date)7 SequenceType (org.apache.cxf.ws.rm.v200702.SequenceType)7 Method (java.lang.reflect.Method)6 Endpoint (org.apache.cxf.endpoint.Endpoint)6 Exchange (org.apache.cxf.message.Exchange)6 AttributedURIType (org.apache.cxf.ws.addressing.AttributedURIType)6 ProtocolVariation (org.apache.cxf.ws.rm.ProtocolVariation)6 RMStore (org.apache.cxf.ws.rm.persistence.RMStore)6