Search in sources :

Example 31 with Identifier

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

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

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

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

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

Aggregations

Identifier (org.apache.cxf.ws.rm.v200702.Identifier)72 Test (org.junit.Test)40 ArrayList (java.util.ArrayList)11 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 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 SoapBinding (org.apache.cxf.binding.soap.SoapBinding)5 ProtocolVariation (org.apache.cxf.ws.rm.ProtocolVariation)5 PreparedStatement (java.sql.PreparedStatement)4