Search in sources :

Example 31 with Identifier

use of org.apache.cxf.ws.rm.v200702.Identifier 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 32 with Identifier

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

the class RMTxStoreTestBase method testCreateDeleteSrcSequences.

@Test
public void testCreateDeleteSrcSequences() {
    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.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();
    try {
        store.createSourceSequence(seq);
        fail("Expected RMStoreException was not thrown.");
    } catch (RMStoreException ex) {
        SQLException se = (SQLException) ex.getCause();
        // duplicate key value
        assertEquals("23505", se.getSQLState());
    }
    control.verify();
    control.reset();
    Identifier sid2 = new Identifier();
    sid2.setValue("sequence2");
    EasyMock.expect(seq.getIdentifier()).andReturn(sid2);
    EasyMock.expect(seq.getExpires()).andReturn(new Date());
    Identifier sid3 = new Identifier();
    sid3.setValue("offeringSequence3");
    EasyMock.expect(seq.getOfferingSequenceIdentifier()).andReturn(sid3);
    EasyMock.expect(seq.getEndpointIdentifier()).andReturn(SERVER_ENDPOINT_ID);
    EasyMock.expect(seq.getProtocol()).andReturn(ProtocolVariation.RM10WSA200408);
    control.replay();
    store.createSourceSequence(seq);
    control.verify();
    store.removeSourceSequence(sid1);
    store.removeSourceSequence(sid2);
    // deleting once again is a no-op
    store.removeSourceSequence(sid2);
}
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) Date(java.util.Date) Test(org.junit.Test)

Example 33 with Identifier

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

the class RMTxStoreTestBase method setupSourceSequence.

private Identifier setupSourceSequence(String s) throws SQLException {
    SourceSequence seq = control.createMock(SourceSequence.class);
    Identifier sid = new Identifier();
    sid.setValue(s);
    Date expiry = null;
    Identifier osid = null;
    Long cmn = ONE;
    boolean lm = false;
    ProtocolVariation pv = ProtocolVariation.RM10WSA200408;
    if ("sequence2".equals(s)) {
        expiry = new Date(System.currentTimeMillis() + 3600 * 1000);
        osid = new Identifier();
        osid.setValue("offeringSequence");
        cmn = TEN;
        lm = true;
        pv = ProtocolVariation.RM11WSA200508;
    }
    EasyMock.expect(seq.getIdentifier()).andReturn(sid);
    EasyMock.expect(seq.getExpires()).andReturn(expiry);
    EasyMock.expect(seq.getOfferingSequenceIdentifier()).andReturn(osid);
    EasyMock.expect(seq.getEndpointIdentifier()).andReturn(CLIENT_ENDPOINT_ID);
    EasyMock.expect(seq.getCurrentMessageNr()).andReturn(cmn);
    EasyMock.expect(seq.isLastMessage()).andReturn(lm);
    EasyMock.expect(seq.getIdentifier()).andReturn(sid);
    EasyMock.expect(seq.getProtocol()).andReturn(pv);
    control.replay();
    store.createSourceSequence(seq);
    Connection con = getConnection();
    try {
        store.beginTransaction();
        store.updateSourceSequence(con, seq);
        store.commit(con);
    } finally {
        releaseConnection(con);
    }
    control.reset();
    return sid;
}
Also used : Identifier(org.apache.cxf.ws.rm.v200702.Identifier) Connection(java.sql.Connection) SourceSequence(org.apache.cxf.ws.rm.SourceSequence) Date(java.util.Date) ProtocolVariation(org.apache.cxf.ws.rm.ProtocolVariation)

Example 34 with Identifier

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

Example 35 with Identifier

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

the class RMTxStoreTestBase method verifySourceSequence.

private void verifySourceSequence(String s, SourceSequence seq) {
    Identifier sid = seq.getIdentifier();
    assertNotNull(sid);
    assertEquals(s, sid.getValue());
    if ("sequence1".equals(s)) {
        assertNull(seq.getExpires());
        assertEquals(1, seq.getCurrentMessageNr());
        assertFalse(seq.isLastMessage());
        assertEquals(ProtocolVariation.RM10WSA200408, seq.getProtocol());
    } else if ("sequence2".equals(s)) {
        Date expires = seq.getExpires();
        assertNotNull(expires);
        expires.after(new Date());
        assertEquals(10, seq.getCurrentMessageNr());
        assertTrue(seq.isLastMessage());
        assertEquals(ProtocolVariation.RM11WSA200508, seq.getProtocol());
    }
}
Also used : Identifier(org.apache.cxf.ws.rm.v200702.Identifier) Date(java.util.Date)

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