Search in sources :

Example 36 with Identifier

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

the class RMTxStoreTwoSchemasTest method testStoreIsolation.

@Test
public void testStoreIsolation() throws Exception {
    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();
    store1.createSourceSequence(seq);
    control.verify();
    SourceSequence rseq = store1.getSourceSequence(sid1);
    assertNotNull(rseq);
    rseq = store2.getSourceSequence(sid1);
    assertNull(rseq);
    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();
    store2.createSourceSequence(seq);
    control.verify();
    rseq = store2.getSourceSequence(sid1);
    assertNotNull(rseq);
    // create another store
    RMTxStore store3 = createStore(null);
    store3.init();
    rseq = store3.getSourceSequence(sid1);
    assertNull(rseq);
    // switch to the store1's schema
    store3.setSchemaName(store1.getSchemaName());
    store3.init();
    rseq = store3.getSourceSequence(sid1);
    assertNotNull(rseq);
}
Also used : Identifier(org.apache.cxf.ws.rm.v200702.Identifier) SourceSequence(org.apache.cxf.ws.rm.SourceSequence) Test(org.junit.Test)

Example 37 with Identifier

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

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

the class RetransmissionQueueImplTest method setUpSequenceType.

private SequenceType setUpSequenceType(Message message, String sid, Long messageNumber) {
    RMProperties rmps = createMock(RMProperties.class);
    if (message != null) {
        message.get(RMMessageConstants.RM_PROPERTIES_OUTBOUND);
        EasyMock.expectLastCall().andReturn(rmps);
    }
    properties.add(rmps);
    SequenceType sequence = createMock(SequenceType.class);
    if (message != null) {
        rmps.getSequence();
        EasyMock.expectLastCall().andReturn(sequence);
    }
    if (messageNumber != null) {
        EasyMock.expect(sequence.getMessageNumber()).andReturn(messageNumber).anyTimes();
    }
    Identifier id = createMock(Identifier.class);
    EasyMock.expect(sequence.getIdentifier()).andReturn(id).anyTimes();
    EasyMock.expect(id.getValue()).andReturn(sid).anyTimes();
    identifiers.add(id);
    sequences.add(sequence);
    return sequence;
}
Also used : Identifier(org.apache.cxf.ws.rm.v200702.Identifier) SequenceType(org.apache.cxf.ws.rm.v200702.SequenceType) RMProperties(org.apache.cxf.ws.rm.RMProperties)

Example 39 with Identifier

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

Example 40 with Identifier

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

the class RMTxStoreTest method testReconnect.

@Test
public void testReconnect() throws Exception {
    // set the initial reconnect delay to 100 msec for testing
    long ird = store.getInitialReconnectDelay();
    store.setInitialReconnectDelay(100);
    SourceSequence seq = control.createMock(SourceSequence.class);
    Identifier sid1 = RMUtils.getWSRMFactory().createIdentifier();
    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);
    // intentionally invalidate the connection
    try {
        store.getConnection().close();
    } catch (SQLException ex) {
    // ignore
    }
    control.replay();
    try {
        store.createSourceSequence(seq);
        fail("Expected RMStoreException was not thrown.");
    } catch (RMStoreException ex) {
        SQLException se = (SQLException) ex.getCause();
        // expects a transient or non-transient connection exception
        assertTrue(se.getSQLState().startsWith("08"));
    }
    // wait 200 msecs to make sure an reconnect is attempted
    Thread.sleep(200);
    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();
    store.createSourceSequence(seq);
    control.verify();
    // revert to the old initial reconnect delay
    store.setInitialReconnectDelay(ird);
    store.removeSourceSequence(sid1);
}
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) Test(org.junit.Test)

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