Search in sources :

Example 1 with DestinationSequence

use of org.apache.cxf.ws.rm.DestinationSequence 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 2 with DestinationSequence

use of org.apache.cxf.ws.rm.DestinationSequence 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)

Example 3 with DestinationSequence

use of org.apache.cxf.ws.rm.DestinationSequence 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)

Example 4 with DestinationSequence

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

the class RMTxStoreTestBase method checkRecoveredDestinationSequences.

private void checkRecoveredDestinationSequences(Collection<DestinationSequence> seqs) {
    for (DestinationSequence recovered : seqs) {
        assertTrue("sequence1".equals(recovered.getIdentifier().getValue()) || "sequence2".equals(recovered.getIdentifier().getValue()));
        assertEquals(Names.WSA_ANONYMOUS_ADDRESS, recovered.getAcksTo().getAddress().getValue());
        if ("sequence1".equals(recovered.getIdentifier().getValue())) {
            assertEquals(0, recovered.getLastMessageNumber());
            assertEquals(1, recovered.getAcknowledgment().getAcknowledgementRange().size());
            SequenceAcknowledgement.AcknowledgementRange r = recovered.getAcknowledgment().getAcknowledgementRange().get(0);
            assertEquals(ONE, r.getLower());
            assertEquals(ONE, r.getUpper());
            assertEquals(ProtocolVariation.RM10WSA200408, recovered.getProtocol());
        } else {
            assertEquals(10, recovered.getLastMessageNumber());
            assertEquals(2, recovered.getAcknowledgment().getAcknowledgementRange().size());
            SequenceAcknowledgement.AcknowledgementRange r = recovered.getAcknowledgment().getAcknowledgementRange().get(0);
            assertEquals(ONE, r.getLower());
            assertEquals(ONE, r.getUpper());
            r = recovered.getAcknowledgment().getAcknowledgementRange().get(1);
            assertEquals(new Long(3), r.getLower());
            assertEquals(TEN, r.getUpper());
            assertEquals(ProtocolVariation.RM11WSA200508, recovered.getProtocol());
        }
    }
}
Also used : DestinationSequence(org.apache.cxf.ws.rm.DestinationSequence) SequenceAcknowledgement(org.apache.cxf.ws.rm.v200702.SequenceAcknowledgement)

Example 5 with DestinationSequence

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

the class RMTxStoreTestBase method testUpdateDestinationSequence.

@Test
public void testUpdateDestinationSequence() throws SQLException, IOException {
    DestinationSequence seq = control.createMock(DestinationSequence.class);
    Identifier sid1 = new Identifier();
    sid1.setValue("sequence1");
    EndpointReferenceType epr = RMUtils.createAnonymousReference();
    EasyMock.expect(seq.getIdentifier()).andReturn(sid1);
    EasyMock.expect(seq.getAcksTo()).andReturn(epr);
    EasyMock.expect(seq.getEndpointIdentifier()).andReturn(SERVER_ENDPOINT_ID);
    EasyMock.expect(seq.getProtocol()).andReturn(ProtocolVariation.RM10WSA200408);
    control.replay();
    store.createDestinationSequence(seq);
    control.verify();
    control.reset();
    EasyMock.expect(seq.getLastMessageNumber()).andReturn(Long.valueOf(0));
    EasyMock.expect(seq.getAcknowledgment()).andReturn(ack1);
    EasyMock.expect(seq.getIdentifier()).andReturn(sid1);
    EasyMock.expect(seq.getProtocol()).andReturn(ProtocolVariation.RM10WSA200408);
    control.replay();
    Connection con = getConnection();
    try {
        store.beginTransaction();
        store.updateDestinationSequence(con, seq);
        store.abort(con);
    } finally {
        releaseConnection(con);
    }
    control.reset();
    EasyMock.expect(seq.getLastMessageNumber()).andReturn(TEN);
    EasyMock.expect(seq.getAcknowledgment()).andReturn(ack1);
    EasyMock.expect(seq.getIdentifier()).andReturn(sid1);
    EasyMock.expect(seq.getProtocol()).andReturn(ProtocolVariation.RM10WSA200408);
    control.replay();
    con = getConnection();
    try {
        store.beginTransaction();
        store.updateDestinationSequence(con, seq);
        store.abort(con);
    } finally {
        releaseConnection(con);
    }
    store.removeDestinationSequence(sid1);
}
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) Test(org.junit.Test)

Aggregations

DestinationSequence (org.apache.cxf.ws.rm.DestinationSequence)11 Identifier (org.apache.cxf.ws.rm.v200702.Identifier)7 EndpointReferenceType (org.apache.cxf.ws.addressing.EndpointReferenceType)6 Test (org.junit.Test)5 Connection (java.sql.Connection)4 RMMessage (org.apache.cxf.ws.rm.persistence.RMMessage)4 SequenceAcknowledgement (org.apache.cxf.ws.rm.v200702.SequenceAcknowledgement)4 SQLException (java.sql.SQLException)3 ProtocolVariation (org.apache.cxf.ws.rm.ProtocolVariation)3 InputStream (java.io.InputStream)2 PreparedStatement (java.sql.PreparedStatement)2 ResultSet (java.sql.ResultSet)2 ArrayList (java.util.ArrayList)2 Message (org.apache.cxf.common.i18n.Message)2 Client (org.apache.cxf.endpoint.Client)2 RMManager (org.apache.cxf.ws.rm.RMManager)2 SourceSequence (org.apache.cxf.ws.rm.SourceSequence)2 RMStore (org.apache.cxf.ws.rm.persistence.RMStore)2 Endpoint (javax.xml.ws.Endpoint)1 RMStoreException (org.apache.cxf.ws.rm.persistence.RMStoreException)1