Search in sources :

Example 61 with Identifier

use of org.geotoolkit.sml.xml.v100.Identifier in project cxf by apache.

the class RMTxStoreTestBase method testCreateSequenceStoreInboundMessage.

@Test
public void testCreateSequenceStoreInboundMessage() throws SQLException, IOException {
    Identifier sid1 = null;
    try {
        DestinationSequence seq = control.createMock(DestinationSequence.class);
        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);
        Collection<DestinationSequence> seqs = store.getDestinationSequences(SERVER_ENDPOINT_ID);
        assertEquals(1, seqs.size());
        DestinationSequence rseq = seqs.iterator().next();
        assertFalse(rseq.isAcknowledged(1));
        Collection<RMMessage> in = store.getMessages(sid1, false);
        assertEquals(0, in.size());
        control.reset();
        EasyMock.expect(seq.getIdentifier()).andReturn(sid1).anyTimes();
        EasyMock.expect(seq.getAcknowledgment()).andReturn(ack1);
        EasyMock.expect(seq.getAcksTo()).andReturn(epr);
        setupInboundMessage(seq, 1L, null);
        in = store.getMessages(sid1, false);
        assertEquals(1, in.size());
        checkRecoveredMessages(in);
        seqs = store.getDestinationSequences(SERVER_ENDPOINT_ID);
        assertEquals(1, seqs.size());
        rseq = seqs.iterator().next();
        assertTrue(rseq.isAcknowledged(1));
        assertFalse(rseq.isAcknowledged(10));
        EasyMock.expect(seq.getIdentifier()).andReturn(sid1).anyTimes();
        EasyMock.expect(seq.getAcknowledgment()).andReturn(ack2);
        EasyMock.expect(seq.getAcksTo()).andReturn(epr);
        control.replay();
        store.persistIncoming(seq, null);
        control.reset();
        seqs = store.getDestinationSequences(SERVER_ENDPOINT_ID);
        assertEquals(1, seqs.size());
        rseq = seqs.iterator().next();
        assertTrue(rseq.isAcknowledged(10));
    } finally {
        if (null != sid1) {
            store.removeDestinationSequence(sid1);
        }
        Collection<Long> msgNrs = Arrays.asList(ONE);
        store.removeMessages(sid1, msgNrs, false);
    }
}
Also used : DestinationSequence(org.apache.cxf.ws.rm.DestinationSequence) Identifier(org.apache.cxf.ws.rm.v200702.Identifier) EndpointReferenceType(org.apache.cxf.ws.addressing.EndpointReferenceType) RMMessage(org.apache.cxf.ws.rm.persistence.RMMessage) Test(org.junit.Test)

Example 62 with Identifier

use of org.geotoolkit.sml.xml.v100.Identifier in project cxf by apache.

the class RMTxStoreTestBase method verifyDestinationSequence.

private void verifyDestinationSequence(String s, DestinationSequence seq) {
    Identifier sid = seq.getIdentifier();
    assertNotNull(sid);
    assertEquals(s, sid.getValue());
    if ("sequence1".equals(s)) {
        assertEquals(0, seq.getLastMessageNumber());
        SequenceAcknowledgement sa = seq.getAcknowledgment();
        assertNotNull(sa);
        verifyAcknowledgementRanges(sa.getAcknowledgementRange(), new long[] { 1, 1 });
        assertEquals(ProtocolVariation.RM10WSA200408, seq.getProtocol());
    } else if ("sequence2".equals(s)) {
        assertEquals(10, seq.getLastMessageNumber());
        SequenceAcknowledgement sa = seq.getAcknowledgment();
        assertNotNull(sa);
        verifyAcknowledgementRanges(sa.getAcknowledgementRange(), new long[] { 1, 1, 3, 10 });
        assertEquals(ProtocolVariation.RM11WSA200508, seq.getProtocol());
    }
}
Also used : Identifier(org.apache.cxf.ws.rm.v200702.Identifier) SequenceAcknowledgement(org.apache.cxf.ws.rm.v200702.SequenceAcknowledgement)

Example 63 with Identifier

use of org.geotoolkit.sml.xml.v100.Identifier in project cxf by apache.

the class RMTxStoreTestBase method testCreateDeleteDestSequences.

@Test
public void testCreateDeleteDestSequences() {
    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.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();
    try {
        store.createDestinationSequence(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);
    epr = RMUtils.createReference(NON_ANON_ACKS_TO);
    EasyMock.expect(seq.getAcksTo()).andReturn(epr);
    EasyMock.expect(seq.getEndpointIdentifier()).andReturn(CLIENT_ENDPOINT_ID);
    EasyMock.expect(seq.getProtocol()).andReturn(ProtocolVariation.RM10WSA200408);
    control.replay();
    store.createDestinationSequence(seq);
    control.verify();
    store.removeDestinationSequence(sid1);
    store.removeDestinationSequence(sid2);
    // deleting once again is a no-op
    store.removeDestinationSequence(sid2);
}
Also used : RMStoreException(org.apache.cxf.ws.rm.persistence.RMStoreException) DestinationSequence(org.apache.cxf.ws.rm.DestinationSequence) Identifier(org.apache.cxf.ws.rm.v200702.Identifier) EndpointReferenceType(org.apache.cxf.ws.addressing.EndpointReferenceType) SQLException(java.sql.SQLException) Test(org.junit.Test)

Example 64 with Identifier

use of org.geotoolkit.sml.xml.v100.Identifier in project cxf by apache.

the class RMManagerTest method testGetExistingSequence.

@Test
public void testGetExistingSequence() throws NoSuchMethodException, SequenceFault, RMException {
    Method m = RMManager.class.getDeclaredMethod("getSource", new Class[] { Message.class });
    manager = control.createMock(RMManager.class, new Method[] { m });
    Message message = control.createMock(Message.class);
    Identifier inSid = control.createMock(Identifier.class);
    Source source = control.createMock(Source.class);
    EasyMock.expect(manager.getSource(message)).andReturn(source);
    SourceSequence sseq = control.createMock(SourceSequence.class);
    EasyMock.expect(source.getCurrent(inSid)).andReturn(sseq);
    control.replay();
    assertSame(sseq, manager.getSequence(inSid, message, null));
    control.verify();
}
Also used : Identifier(org.apache.cxf.ws.rm.v200702.Identifier) RMMessage(org.apache.cxf.ws.rm.persistence.RMMessage) Message(org.apache.cxf.message.Message) Method(java.lang.reflect.Method) Test(org.junit.Test)

Example 65 with Identifier

use of org.geotoolkit.sml.xml.v100.Identifier in project cxf by apache.

the class EncoderDecoder10AImpl method buildHeaderFaultObject.

@Override
protected Object buildHeaderFaultObject(SequenceFault sf) {
    org.apache.cxf.ws.rm.v200502wsa15.SequenceFaultType flt = new org.apache.cxf.ws.rm.v200502wsa15.SequenceFaultType();
    flt.setFaultCode(sf.getFaultCode());
    Object detail = sf.getDetail();
    if (detail instanceof Element) {
        flt.getAny().add(detail);
    } else if (detail instanceof Identifier) {
        flt.getAny().add(VersionTransformer.convert200502wsa15((Identifier) detail));
    } else if (detail instanceof SequenceAcknowledgement) {
        flt.getAny().add(VersionTransformer.convert200502wsa15((SequenceAcknowledgement) detail));
    }
    Element data = sf.getExtraDetail();
    if (data != null) {
        flt.getAny().add(data);
    }
    return flt;
}
Also used : Identifier(org.apache.cxf.ws.rm.v200702.Identifier) JAXBElement(javax.xml.bind.JAXBElement) Element(org.w3c.dom.Element) SequenceAcknowledgement(org.apache.cxf.ws.rm.v200702.SequenceAcknowledgement)

Aggregations

Identifier (org.apache.cxf.ws.rm.v200702.Identifier)72 Test (org.junit.Test)43 ArrayList (java.util.ArrayList)13 Message (org.apache.cxf.message.Message)11 SourceSequence (org.apache.cxf.ws.rm.SourceSequence)11 RMMessage (org.apache.cxf.ws.rm.persistence.RMMessage)11 SequenceAcknowledgement (org.apache.cxf.ws.rm.v200702.SequenceAcknowledgement)11 Connection (java.sql.Connection)9 AddressingProperties (org.apache.cxf.ws.addressing.AddressingProperties)8 SQLException (java.sql.SQLException)7 Date (java.util.Date)7 EndpointReferenceType (org.apache.cxf.ws.addressing.EndpointReferenceType)7 DestinationSequence (org.apache.cxf.ws.rm.DestinationSequence)7 InputStream (java.io.InputStream)6 Method (java.lang.reflect.Method)6 AttributedURIType (org.apache.cxf.ws.addressing.AttributedURIType)6 RMStore (org.apache.cxf.ws.rm.persistence.RMStore)6 SequenceType (org.apache.cxf.ws.rm.v200702.SequenceType)6 JAXBElement (javax.xml.bind.JAXBElement)5 SoapBinding (org.apache.cxf.binding.soap.SoapBinding)5