Search in sources :

Example 76 with Identifier

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

the class ProxyTest method testCreateSequence.

@SuppressWarnings("unchecked")
private void testCreateSequence(boolean isServer) throws NoSuchMethodException, RMException {
    Method m = Proxy.class.getDeclaredMethod("invoke", new Class[] { OperationInfo.class, ProtocolVariation.class, Object[].class, Map.class, Exchange.class });
    Proxy proxy = EasyMock.createMockBuilder(Proxy.class).addMockedMethod(m).createMock(control);
    proxy.setReliableEndpoint(rme);
    RMManager manager = control.createMock(RMManager.class);
    EasyMock.expect(rme.getManager()).andReturn(manager).anyTimes();
    SourcePolicyType sp = control.createMock(SourcePolicyType.class);
    EasyMock.expect(manager.getSourcePolicy()).andReturn(sp).anyTimes();
    EasyMock.expect(sp.getAcksTo()).andReturn(null).anyTimes();
    Duration d = DatatypeFactory.createDuration("PT12H");
    EasyMock.expect(sp.getSequenceExpiration()).andReturn(d).anyTimes();
    EasyMock.expect(sp.isIncludeOffer()).andReturn(Boolean.TRUE).anyTimes();
    Duration dOffered = DatatypeFactory.createDuration("PT24H");
    EasyMock.expect(sp.getOfferedSequenceExpiration()).andReturn(dOffered).anyTimes();
    Source source = control.createMock(Source.class);
    EasyMock.expect(rme.getSource()).andReturn(source).anyTimes();
    Identifier offeredId = control.createMock(Identifier.class);
    EasyMock.expect(source.generateSequenceIdentifier()).andReturn(offeredId).anyTimes();
    Endpoint endpoint = control.createMock(Endpoint.class);
    EasyMock.expect(rme.getEndpoint(ProtocolVariation.RM10WSA200408)).andReturn(endpoint).anyTimes();
    EndpointInfo epi = control.createMock(EndpointInfo.class);
    EasyMock.expect(endpoint.getEndpointInfo()).andReturn(epi).anyTimes();
    ServiceInfo si = control.createMock(ServiceInfo.class);
    EasyMock.expect(epi.getService()).andReturn(si).anyTimes();
    InterfaceInfo ii = control.createMock(InterfaceInfo.class);
    EasyMock.expect(si.getInterface()).andReturn(ii).anyTimes();
    OperationInfo oi = control.createMock(OperationInfo.class);
    org.apache.cxf.ws.rm.v200502.CreateSequenceResponseType csr = null;
    if (isServer) {
        EasyMock.expect(ii.getOperation(RM10Constants.CREATE_SEQUENCE_ONEWAY_QNAME)).andReturn(oi).anyTimes();
        Endpoint ae = control.createMock(Endpoint.class);
        EasyMock.expect(rme.getApplicationEndpoint()).andReturn(ae).anyTimes();
        EasyMock.expect(ae.getExecutor()).andReturn(SynchronousExecutor.getInstance()).anyTimes();
    } else {
        EasyMock.expect(ii.getOperation(RM10Constants.CREATE_SEQUENCE_QNAME)).andReturn(oi).anyTimes();
        csr = new org.apache.cxf.ws.rm.v200502.CreateSequenceResponseType();
    }
    ExchangeImpl exchange = new ExchangeImpl();
    EasyMock.expect(proxy.invoke(EasyMock.same(oi), EasyMock.isA(ProtocolVariation.class), EasyMock.isA(Object[].class), EasyMock.isA(Map.class), EasyMock.isA(Exchange.class))).andReturn(csr).anyTimes();
    EndpointReferenceType defaultAcksTo = control.createMock(EndpointReferenceType.class);
    AttributedURIType aut = control.createMock(AttributedURIType.class);
    EasyMock.expect(aut.getValue()).andReturn("here").anyTimes();
    EasyMock.expect(defaultAcksTo.getAddress()).andReturn(aut).anyTimes();
    RelatesToType relatesTo = control.createMock(RelatesToType.class);
    control.replay();
    Map<String, Object> context = new HashMap<>();
    if (isServer) {
        assertNull(proxy.createSequence(defaultAcksTo, relatesTo, isServer, ProtocolVariation.RM10WSA200408, exchange, context));
    } else {
        assertNotNull(proxy.createSequence(defaultAcksTo, relatesTo, isServer, ProtocolVariation.RM10WSA200408, exchange, context));
    }
}
Also used : BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) OperationInfo(org.apache.cxf.service.model.OperationInfo) EndpointReferenceType(org.apache.cxf.ws.addressing.EndpointReferenceType) HashMap(java.util.HashMap) AttributedURIType(org.apache.cxf.ws.addressing.AttributedURIType) Duration(javax.xml.datatype.Duration) Method(java.lang.reflect.Method) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) RelatesToType(org.apache.cxf.ws.addressing.RelatesToType) Identifier(org.apache.cxf.ws.rm.v200702.Identifier) Endpoint(org.apache.cxf.endpoint.Endpoint) SourcePolicyType(org.apache.cxf.ws.rm.manager.SourcePolicyType) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo) ExchangeImpl(org.apache.cxf.message.ExchangeImpl)

Example 77 with Identifier

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

the class ServantTest method testInvokeForCloseSequence.

@Test
public void testInvokeForCloseSequence() {
    RMEndpoint rme = control.createMock(RMEndpoint.class);
    RMManager manager = new RMManager();
    Destination destination = new Destination(rme);
    Source source = new Source(rme);
    DestinationSequence seq = control.createMock(DestinationSequence.class);
    org.apache.cxf.ws.rm.v200702.Identifier sid = new org.apache.cxf.ws.rm.v200702.Identifier();
    sid.setValue("123");
    EasyMock.expect(seq.getIdentifier()).andReturn(sid).anyTimes();
    EasyMock.expect(rme.getDestination()).andReturn(destination).anyTimes();
    EasyMock.expect(rme.getManager()).andReturn(manager).anyTimes();
    EasyMock.expect(rme.getSource()).andReturn(source).anyTimes();
    Message message = createTestCloseSequenceMessage(sid.getValue());
    BindingOperationInfo boi = control.createMock(BindingOperationInfo.class);
    OperationInfo oi = control.createMock(OperationInfo.class);
    EasyMock.expect(boi.getOperationInfo()).andReturn(oi).anyTimes();
    EasyMock.expect(oi.getName()).andReturn(RM11Constants.INSTANCE.getCloseSequenceOperationName()).anyTimes();
    message.getExchange().put(BindingOperationInfo.class, boi);
    control.replay();
    TestServant servant = new TestServant(rme);
    servant.invoke(message.getExchange(), message.getContent(List.class).get(0));
    assertTrue(servant.called);
}
Also used : BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) OperationInfo(org.apache.cxf.service.model.OperationInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) Message(org.apache.cxf.message.Message) Identifier(org.apache.cxf.ws.rm.v200502.Identifier) Test(org.junit.Test)

Example 78 with Identifier

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

the class SourceSequenceTest method testEqualsAndHashCode.

@Test
public void testEqualsAndHashCode() {
    SourceSequence seq = new SourceSequence(id, ProtocolVariation.RM10WSA200408);
    SourceSequence otherSeq = null;
    assertFalse(seq.equals(otherSeq));
    otherSeq = new SourceSequence(id, ProtocolVariation.RM10WSA200408);
    assertEquals(seq, otherSeq);
    assertEquals(seq.hashCode(), otherSeq.hashCode());
    Identifier otherId = factory.createIdentifier();
    otherId.setValue("otherSeq");
    otherSeq = new SourceSequence(otherId, ProtocolVariation.RM10WSA200408);
    assertFalse(seq.equals(otherSeq));
    assertTrue(seq.hashCode() != otherSeq.hashCode());
}
Also used : Identifier(org.apache.cxf.ws.rm.v200702.Identifier) Test(org.junit.Test)

Example 79 with Identifier

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

the class SourceSequenceTest method testConstructors.

@Test
public void testConstructors() {
    Identifier otherId = factory.createIdentifier();
    otherId.setValue("otherSeq");
    SourceSequence seq = new SourceSequence(id, ProtocolVariation.RM10WSA200408);
    assertEquals(id, seq.getIdentifier());
    assertFalse(seq.isLastMessage());
    assertFalse(seq.isExpired());
    assertEquals(0, seq.getCurrentMessageNr());
    assertNotNull(seq.getAcknowledgement());
    assertEquals(0, seq.getAcknowledgement().getAcknowledgementRange().size());
    assertFalse(seq.allAcknowledged());
    assertFalse(seq.offeredBy(otherId));
    Date expiry = new Date(System.currentTimeMillis() + 3600 * 1000);
    seq = new SourceSequence(id, expiry, null, ProtocolVariation.RM10WSA200408);
    assertEquals(id, seq.getIdentifier());
    assertFalse(seq.isLastMessage());
    assertFalse(seq.isExpired());
    assertEquals(0, seq.getCurrentMessageNr());
    assertNotNull(seq.getAcknowledgement());
    assertEquals(0, seq.getAcknowledgement().getAcknowledgementRange().size());
    assertFalse(seq.allAcknowledged());
    assertFalse(seq.offeredBy(otherId));
    seq = new SourceSequence(id, expiry, otherId, ProtocolVariation.RM10WSA200408);
    assertTrue(seq.offeredBy(otherId));
    assertFalse(seq.offeredBy(id));
}
Also used : Identifier(org.apache.cxf.ws.rm.v200702.Identifier) Date(java.util.Date) Test(org.junit.Test)

Example 80 with Identifier

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

the class SourceSequenceTest method testCheckOfferingSequenceClosed.

@Test
public void testCheckOfferingSequenceClosed() {
    setUpSource();
    RMEndpoint rme = control.createMock(RMEndpoint.class);
    EasyMock.expect(source.getReliableEndpoint()).andReturn(rme).anyTimes();
    Destination destination = control.createMock(Destination.class);
    EasyMock.expect(rme.getDestination()).andReturn(destination).anyTimes();
    DestinationSequence dseq = control.createMock(DestinationSequence.class);
    Identifier did = control.createMock(Identifier.class);
    EasyMock.expect(destination.getSequence(did)).andReturn(dseq).anyTimes();
    EasyMock.expect(dseq.getLastMessageNumber()).andReturn(Long.valueOf(1)).anyTimes();
    EasyMock.expect(did.getValue()).andReturn("dseq").anyTimes();
    control.replay();
    SourceSequence seq = new SourceSequence(id, null, did, ProtocolVariation.RM10WSA200408);
    seq.setSource(source);
    seq.nextMessageNumber(did, 1, false);
    assertTrue(seq.isLastMessage());
    control.verify();
}
Also used : Identifier(org.apache.cxf.ws.rm.v200702.Identifier) Test(org.junit.Test)

Aggregations

Identifier (org.apache.cxf.ws.rm.v200702.Identifier)72 Test (org.junit.Test)43 Message (org.apache.cxf.message.Message)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 ArrayList (java.util.ArrayList)9 AddressingProperties (org.apache.cxf.ws.addressing.AddressingProperties)9 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 Method (java.lang.reflect.Method)6 Endpoint (org.apache.cxf.endpoint.Endpoint)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 SequenceType (org.apache.cxf.ws.rm.v200702.SequenceType)6 PreparedStatement (java.sql.PreparedStatement)5