Search in sources :

Example 41 with Identifier

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.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 = Arrays.asList(ONE);
        store.removeMessages(sid1, msgNrs, true);
    }
}
Also used : Identifier(org.apache.cxf.ws.rm.v200702.Identifier) RMMessage(org.apache.cxf.ws.rm.persistence.RMMessage) SourceSequence(org.apache.cxf.ws.rm.SourceSequence) Test(org.junit.Test)

Example 42 with Identifier

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.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 43 with Identifier

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.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 44 with Identifier

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.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)

Example 45 with Identifier

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.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)

Aggregations

Identifier (org.apache.cxf.ws.rm.v200702.Identifier)72 ArrayList (java.util.ArrayList)71 Uint64 (org.opendaylight.yangtools.yang.common.Uint64)59 Test (org.junit.Test)52 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)50 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)50 ExecutionException (java.util.concurrent.ExecutionException)38 Uint32 (org.opendaylight.yangtools.yang.common.Uint32)37 Logger (org.slf4j.Logger)35 LoggerFactory (org.slf4j.LoggerFactory)35 Inject (javax.inject.Inject)32 Singleton (javax.inject.Singleton)32 DataBroker (org.opendaylight.mdsal.binding.api.DataBroker)32 LogicalDatastoreType (org.opendaylight.mdsal.common.api.LogicalDatastoreType)32 PreDestroy (javax.annotation.PreDestroy)30 ManagedNewTransactionRunner (org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunner)30 ManagedNewTransactionRunnerImpl (org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunnerImpl)30 Executors (org.opendaylight.infrautils.utils.concurrent.Executors)28 CONFIGURATION (org.opendaylight.mdsal.binding.util.Datastore.CONFIGURATION)27 AbstractAsyncDataTreeChangeListener (org.opendaylight.serviceutils.tools.listener.AbstractAsyncDataTreeChangeListener)26