Search in sources :

Example 11 with SourceSequence

use of org.apache.cxf.ws.rm.SourceSequence in project cxf by apache.

the class RMTxStoreTestBase method testGetSourceSequence.

@Test
public void testGetSourceSequence() throws SQLException, IOException {
    Identifier sid1 = null;
    Identifier sid2 = null;
    SourceSequence seq = store.getSourceSequence(new Identifier());
    assertNull(seq);
    try {
        sid1 = setupSourceSequence("sequence1");
        seq = store.getSourceSequence(sid1);
        assertNotNull(seq);
        verifySourceSequence("sequence1", seq);
        sid2 = setupSourceSequence("sequence2");
        seq = store.getSourceSequence(sid2);
        assertNotNull(seq);
        verifySourceSequence("sequence2", seq);
    } finally {
        if (null != sid1) {
            store.removeSourceSequence(sid1);
        }
        if (null != sid2) {
            store.removeSourceSequence(sid2);
        }
    }
}
Also used : Identifier(org.apache.cxf.ws.rm.v200702.Identifier) SourceSequence(org.apache.cxf.ws.rm.SourceSequence) Test(org.junit.Test)

Example 12 with SourceSequence

use of org.apache.cxf.ws.rm.SourceSequence in project cxf by apache.

the class RetransmissionQueueImplTest method testCountUnacknowledgedUnknownSequence.

@Test
public void testCountUnacknowledgedUnknownSequence() {
    Long[] messageNumbers = { TEN, ONE };
    SourceSequence sequence = setUpSequence("sequence1", messageNumbers, null);
    ready(false);
    assertEquals("unexpected unacked count", 0, queue.countUnacknowledged(sequence));
}
Also used : SourceSequence(org.apache.cxf.ws.rm.SourceSequence) Test(org.junit.Test)

Example 13 with SourceSequence

use of org.apache.cxf.ws.rm.SourceSequence in project cxf by apache.

the class RetransmissionQueueImplTest method testCountUnacknowledged.

@Test
public void testCountUnacknowledged() {
    Long[] messageNumbers = { TEN, ONE };
    SourceSequence sequence = setUpSequence("sequence1", messageNumbers, null);
    List<RetransmissionQueueImpl.ResendCandidate> sequenceList = new ArrayList<RetransmissionQueueImpl.ResendCandidate>();
    queue.getUnacknowledged().put("sequence1", sequenceList);
    SoapMessage message1 = setUpMessage("sequence1", messageNumbers[0], false);
    setupMessagePolicies(message1);
    SoapMessage message2 = setUpMessage("sequence1", messageNumbers[1], false);
    setupMessagePolicies(message2);
    ready(false);
    sequenceList.add(queue.createResendCandidate(message1));
    sequenceList.add(queue.createResendCandidate(message2));
    assertEquals("unexpected unacked count", 2, queue.countUnacknowledged(sequence));
    assertTrue("queue is empty", !queue.isEmpty());
}
Also used : ArrayList(java.util.ArrayList) SourceSequence(org.apache.cxf.ws.rm.SourceSequence) SoapMessage(org.apache.cxf.binding.soap.SoapMessage) Test(org.junit.Test)

Example 14 with SourceSequence

use of org.apache.cxf.ws.rm.SourceSequence in project cxf by apache.

the class RetransmissionQueueImplTest method testPurgeAcknowledgedAll.

@Test
public void testPurgeAcknowledgedAll() {
    Long[] messageNumbers = { TEN, ONE };
    SourceSequence sequence = setUpSequence("sequence1", messageNumbers, new boolean[] { true, true });
    List<RetransmissionQueueImpl.ResendCandidate> sequenceList = new ArrayList<RetransmissionQueueImpl.ResendCandidate>();
    queue.getUnacknowledged().put("sequence1", sequenceList);
    SoapMessage message1 = setUpMessage("sequence1", messageNumbers[0]);
    setupMessagePolicies(message1);
    SoapMessage message2 = setUpMessage("sequence1", messageNumbers[1]);
    setupMessagePolicies(message2);
    endpoint.handleAcknowledgment("sequence1", TEN, message1);
    EasyMock.expectLastCall();
    endpoint.handleAcknowledgment("sequence1", ONE, message2);
    EasyMock.expectLastCall();
    ready(false);
    sequenceList.add(queue.createResendCandidate(message1));
    sequenceList.add(queue.createResendCandidate(message2));
    queue.purgeAcknowledged(sequence);
    assertEquals("unexpected unacked map size", 0, queue.getUnacknowledged().size());
    assertEquals("unexpected unacked list size", 0, sequenceList.size());
}
Also used : ArrayList(java.util.ArrayList) SourceSequence(org.apache.cxf.ws.rm.SourceSequence) SoapMessage(org.apache.cxf.binding.soap.SoapMessage) Test(org.junit.Test)

Example 15 with SourceSequence

use of org.apache.cxf.ws.rm.SourceSequence in project cxf by apache.

the class RetransmissionQueueImplTest method setUpSequence.

private SourceSequence setUpSequence(String sid, Long[] messageNumbers, boolean[] isAcked) {
    SourceSequence sequence = createMock(SourceSequence.class);
    Identifier id = createMock(Identifier.class);
    sequence.getIdentifier();
    EasyMock.expectLastCall().andReturn(id).anyTimes();
    id.getValue();
    EasyMock.expectLastCall().andReturn(sid).anyTimes();
    identifiers.add(id);
    Source source = createMock(Source.class);
    sequence.getSource();
    EasyMock.expectLastCall().andReturn(source).anyTimes();
    source.getReliableEndpoint();
    EasyMock.expectLastCall().andReturn(endpoint).anyTimes();
    boolean includesAcked = false;
    for (int i = 0; isAcked != null && i < isAcked.length; i++) {
        sequence.isAcknowledged(messageNumbers[i]);
        EasyMock.expectLastCall().andReturn(isAcked[i]);
        if (isAcked[i]) {
            includesAcked = true;
        }
    }
    if (includesAcked) {
        RMStore store = createMock(RMStore.class);
        manager.getStore();
        EasyMock.expectLastCall().andReturn(store);
    }
    return sequence;
}
Also used : Identifier(org.apache.cxf.ws.rm.v200702.Identifier) RMStore(org.apache.cxf.ws.rm.persistence.RMStore) SourceSequence(org.apache.cxf.ws.rm.SourceSequence) Source(org.apache.cxf.ws.rm.Source) RMEndpoint(org.apache.cxf.ws.rm.RMEndpoint)

Aggregations

SourceSequence (org.apache.cxf.ws.rm.SourceSequence)19 Test (org.junit.Test)12 Identifier (org.apache.cxf.ws.rm.v200702.Identifier)11 ArrayList (java.util.ArrayList)6 Connection (java.sql.Connection)4 SQLException (java.sql.SQLException)4 Date (java.util.Date)4 SoapMessage (org.apache.cxf.binding.soap.SoapMessage)4 RMMessage (org.apache.cxf.ws.rm.persistence.RMMessage)4 ProtocolVariation (org.apache.cxf.ws.rm.ProtocolVariation)3 RMStore (org.apache.cxf.ws.rm.persistence.RMStore)3 PreparedStatement (java.sql.PreparedStatement)2 ResultSet (java.sql.ResultSet)2 Message (org.apache.cxf.common.i18n.Message)2 Client (org.apache.cxf.endpoint.Client)2 DestinationSequence (org.apache.cxf.ws.rm.DestinationSequence)2 RMManager (org.apache.cxf.ws.rm.RMManager)2 RMStoreException (org.apache.cxf.ws.rm.persistence.RMStoreException)2 Endpoint (javax.xml.ws.Endpoint)1 RMEndpoint (org.apache.cxf.ws.rm.RMEndpoint)1