Search in sources :

Example 6 with SourceSequence

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

the class RetransmissionQueueImplTest method testPurgeAcknowledgedNone.

@Test
public void testPurgeAcknowledgedNone() {
    Long[] messageNumbers = { TEN, ONE };
    SourceSequence sequence = setUpSequence("sequence1", messageNumbers, new boolean[] { false, false });
    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);
    ready(false);
    sequenceList.add(queue.createResendCandidate(message1));
    sequenceList.add(queue.createResendCandidate(message2));
    queue.purgeAcknowledged(sequence);
    assertEquals("unexpected unacked map size", 1, queue.getUnacknowledged().size());
    assertEquals("unexpected unacked list size", 2, 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 7 with SourceSequence

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

the class RetransmissionQueueImplTest method testPurgeAcknowledgedSome.

@Test
public void testPurgeAcknowledgedSome() {
    Long[] messageNumbers = { TEN, ONE };
    SourceSequence sequence = setUpSequence("sequence1", messageNumbers, new boolean[] { true, false });
    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();
    ready(false);
    sequenceList.add(queue.createResendCandidate(message1));
    sequenceList.add(queue.createResendCandidate(message2));
    queue.purgeAcknowledged(sequence);
    assertEquals("unexpected unacked map size", 1, queue.getUnacknowledged().size());
    assertEquals("unexpected unacked list size", 1, 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 8 with SourceSequence

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

the class RMTxStoreTest method testReconnect.

@Test
public void testReconnect() throws Exception {
    // set the initial reconnect delay to 100 msec for testing
    long ird = store.getInitialReconnectDelay();
    store.setInitialReconnectDelay(100);
    SourceSequence seq = control.createMock(SourceSequence.class);
    Identifier sid1 = RMUtils.getWSRMFactory().createIdentifier();
    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);
    // intentionally invalidate the connection
    try {
        store.getConnection().close();
    } catch (SQLException ex) {
    // ignore
    }
    control.replay();
    try {
        store.createSourceSequence(seq);
        fail("Expected RMStoreException was not thrown.");
    } catch (RMStoreException ex) {
        SQLException se = (SQLException) ex.getCause();
        // expects a transient or non-transient connection exception
        assertTrue(se.getSQLState().startsWith("08"));
    }
    // wait 200 msecs to make sure an reconnect is attempted
    Thread.sleep(200);
    control.reset();
    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.verify();
    // revert to the old initial reconnect delay
    store.setInitialReconnectDelay(ird);
    store.removeSourceSequence(sid1);
}
Also used : RMStoreException(org.apache.cxf.ws.rm.persistence.RMStoreException) Identifier(org.apache.cxf.ws.rm.v200702.Identifier) SQLException(java.sql.SQLException) SourceSequence(org.apache.cxf.ws.rm.SourceSequence) Test(org.junit.Test)

Example 9 with SourceSequence

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

the class RMTxStoreTestBase method testUpdateSourceSequence.

@Test
public void testUpdateSourceSequence() throws SQLException {
    SourceSequence seq = control.createMock(SourceSequence.class);
    Identifier 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.verify();
    control.reset();
    EasyMock.expect(seq.getCurrentMessageNr()).andReturn(ONE);
    EasyMock.expect(seq.isLastMessage()).andReturn(false);
    EasyMock.expect(seq.getIdentifier()).andReturn(sid1);
    EasyMock.expect(seq.getProtocol()).andReturn(ProtocolVariation.RM10WSA200408);
    control.replay();
    Connection con = getConnection();
    try {
        store.beginTransaction();
        store.updateSourceSequence(con, seq);
        store.abort(con);
    } finally {
        releaseConnection(con);
    }
    control.reset();
    EasyMock.expect(seq.getCurrentMessageNr()).andReturn(TEN);
    EasyMock.expect(seq.isLastMessage()).andReturn(true);
    EasyMock.expect(seq.getIdentifier()).andReturn(sid1);
    EasyMock.expect(seq.getProtocol()).andReturn(ProtocolVariation.RM10WSA200408);
    control.replay();
    con = getConnection();
    try {
        store.beginTransaction();
        store.updateSourceSequence(con, seq);
        store.abort(con);
    } finally {
        releaseConnection(con);
    }
    store.removeSourceSequence(sid1);
}
Also used : Identifier(org.apache.cxf.ws.rm.v200702.Identifier) Connection(java.sql.Connection) SourceSequence(org.apache.cxf.ws.rm.SourceSequence) Test(org.junit.Test)

Example 10 with SourceSequence

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

the class RMTxStoreTestBase method testGetSourceSequences.

@Test
public void testGetSourceSequences() throws SQLException {
    Identifier sid1 = null;
    Identifier sid2 = null;
    Collection<SourceSequence> seqs = store.getSourceSequences("unknown");
    assertEquals(0, seqs.size());
    try {
        sid1 = setupSourceSequence("sequence1");
        seqs = store.getSourceSequences(CLIENT_ENDPOINT_ID);
        assertEquals(1, seqs.size());
        checkRecoveredSourceSequences(seqs);
        sid2 = setupSourceSequence("sequence2");
        seqs = store.getSourceSequences(CLIENT_ENDPOINT_ID);
        assertEquals(2, seqs.size());
        checkRecoveredSourceSequences(seqs);
    } 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)

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