Search in sources :

Example 16 with Identifier

use of org.geotoolkit.sml.xml.v101.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 17 with Identifier

use of org.geotoolkit.sml.xml.v101.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)

Example 18 with Identifier

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

the class RMTxStoreTestBase method testGetMessages.

@Test
public void testGetMessages() throws SQLException, IOException {
    Identifier sid1 = new Identifier();
    sid1.setValue("sequence1");
    Identifier sid2 = new Identifier();
    sid2.setValue("sequence2");
    Collection<RMMessage> out = store.getMessages(sid1, true);
    assertEquals(0, out.size());
    Collection<RMMessage> in = store.getMessages(sid1, false);
    assertEquals(0, in.size());
    try {
        setupMessage(sid1, ONE, null, true);
        setupMessage(sid1, ONE, null, false);
        out = store.getMessages(sid1, true);
        assertEquals(1, out.size());
        checkRecoveredMessages(out);
        in = store.getMessages(sid1, false);
        assertEquals(1, in.size());
        checkRecoveredMessages(in);
        setupMessage(sid1, TEN, NON_ANON_ACKS_TO, true);
        setupMessage(sid1, TEN, NON_ANON_ACKS_TO, false);
        out = store.getMessages(sid1, true);
        assertEquals(2, out.size());
        checkRecoveredMessages(out);
        in = store.getMessages(sid1, false);
        assertEquals(2, in.size());
        checkRecoveredMessages(in);
    } finally {
        Collection<Long> msgNrs = Arrays.asList(ONE, TEN);
        store.removeMessages(sid1, msgNrs, true);
        store.removeMessages(sid1, msgNrs, false);
    }
}
Also used : Identifier(org.apache.cxf.ws.rm.v200702.Identifier) RMMessage(org.apache.cxf.ws.rm.persistence.RMMessage) Test(org.junit.Test)

Example 19 with Identifier

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

the class RMSoapOutInterceptorTest method testEncodeFault.

@Test
public void testEncodeFault() throws Exception {
    RMSoapOutInterceptor codec = new RMSoapOutInterceptor();
    setUpOutbound();
    SoapMessage message = setupOutboundFaultMessage();
    // no RM headers and no fault
    codec.encode(message);
    verifyHeaders(message, new String[] {});
    // fault is not a SoapFault
    message = setupOutboundFaultMessage();
    assertTrue(MessageUtils.isFault(message));
    Exception ex = new RuntimeException("");
    message.setContent(Exception.class, ex);
    codec.encode(message);
    verifyHeaders(message, new String[] {});
    // fault is a SoapFault but does not have a SequenceFault cause
    message = setupOutboundFaultMessage();
    SoapFault f = new SoapFault("REASON", RM10Constants.UNKNOWN_SEQUENCE_FAULT_QNAME);
    message.setContent(Exception.class, f);
    codec.encode(message);
    verifyHeaders(message, new String[] {});
    // fault is a SoapFault and has a SequenceFault cause
    message = setupOutboundFaultMessage();
    SequenceFault sf = new SequenceFault("REASON");
    sf.setFaultCode(RM10Constants.UNKNOWN_SEQUENCE_FAULT_QNAME);
    Identifier sid = new Identifier();
    sid.setValue("SID");
    sf.setSender(true);
    f.initCause(sf);
    message.setContent(Exception.class, f);
    codec.encode(message);
    verifyHeaders(message, new String[] { RMConstants.SEQUENCE_FAULT_NAME });
}
Also used : SequenceFault(org.apache.cxf.ws.rm.SequenceFault) SoapFault(org.apache.cxf.binding.soap.SoapFault) Identifier(org.apache.cxf.ws.rm.v200702.Identifier) SoapMessage(org.apache.cxf.binding.soap.SoapMessage) Test(org.junit.Test)

Example 20 with Identifier

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

the class SoapFaultFactoryTest method createSoap12Fault.

@Test
public void createSoap12Fault() {
    SoapBinding sb = control.createMock(SoapBinding.class);
    EasyMock.expect(sb.getSoapVersion()).andReturn(Soap12.getInstance());
    Identifier id = new Identifier();
    id.setValue("sid");
    setupSequenceFault(true, RM10Constants.UNKNOWN_SEQUENCE_FAULT_QNAME, id);
    control.replay();
    SoapFaultFactory factory = new SoapFaultFactory(sb);
    SoapFault fault = (SoapFault) factory.createFault(sf, createInboundMessage());
    assertEquals("reason", fault.getReason());
    assertEquals(Soap12.getInstance().getSender(), fault.getFaultCode());
    assertEquals(RM10Constants.UNKNOWN_SEQUENCE_FAULT_QNAME, fault.getSubCode());
    Element elem = fault.getDetail();
    assertEquals(RM10Constants.NAMESPACE_URI, elem.getNamespaceURI());
    assertEquals("Identifier", elem.getLocalName());
    assertNull(fault.getCause());
    control.verify();
}
Also used : SoapFault(org.apache.cxf.binding.soap.SoapFault) Identifier(org.apache.cxf.ws.rm.v200702.Identifier) Element(org.w3c.dom.Element) SoapBinding(org.apache.cxf.binding.soap.SoapBinding) Test(org.junit.Test)

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