Search in sources :

Example 66 with Identifier

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

the class AbstractSequenceTest method testIdentifierEquals.

@Test
public void testIdentifierEquals() {
    Identifier id1 = null;
    Identifier id2 = null;
    assertTrue(AbstractSequence.identifierEquals(id1, id2));
    ObjectFactory factory = new ObjectFactory();
    id1 = factory.createIdentifier();
    id1.setValue("seq1");
    assertTrue(!AbstractSequence.identifierEquals(id1, id2));
    id2 = factory.createIdentifier();
    id2.setValue("seq2");
    assertTrue(!AbstractSequence.identifierEquals(id1, id2));
    id2.setValue("seq1");
    assertTrue(AbstractSequence.identifierEquals(id1, id2));
}
Also used : Identifier(org.apache.cxf.ws.rm.v200702.Identifier) ObjectFactory(org.apache.cxf.ws.rm.v200702.ObjectFactory) Test(org.junit.Test)

Example 67 with Identifier

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

the class DestinationSequenceTest method testConstructors.

@Test
public void testConstructors() {
    Identifier otherId = factory.createIdentifier();
    otherId.setValue("otherSeq");
    DestinationSequence seq = new DestinationSequence(id, ref, destination, ProtocolVariation.RM10WSA200408);
    assertEquals(id, seq.getIdentifier());
    assertEquals(0, seq.getLastMessageNumber());
    assertSame(ref, seq.getAcksTo());
    assertNotNull(seq.getAcknowledgment());
    assertNotNull(seq.getMonitor());
    SequenceAcknowledgement ack = new SequenceAcknowledgement();
    seq = new DestinationSequence(id, ref, 10, ack, ProtocolVariation.RM10WSA200408);
    assertEquals(id, seq.getIdentifier());
    assertEquals(10, seq.getLastMessageNumber());
    assertSame(ref, seq.getAcksTo());
    assertSame(ack, seq.getAcknowledgment());
    assertNotNull(seq.getMonitor());
}
Also used : Identifier(org.apache.cxf.ws.rm.v200702.Identifier) SequenceAcknowledgement(org.apache.cxf.ws.rm.v200702.SequenceAcknowledgement) Test(org.junit.Test)

Example 68 with Identifier

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

the class DestinationTest method testAddRemoveSequence.

@Test
public void testAddRemoveSequence() {
    DestinationSequence ds = control.createMock(DestinationSequence.class);
    ds.setDestination(destination);
    EasyMock.expectLastCall();
    Identifier id = control.createMock(Identifier.class);
    EasyMock.expect(ds.getIdentifier()).andReturn(id).times(3);
    String sid = "s1";
    EasyMock.expect(id.getValue()).andReturn(sid).times(3);
    RMManager manager = control.createMock(RMManager.class);
    EasyMock.expect(rme.getManager()).andReturn(manager).times(2);
    RMStore store = control.createMock(RMStore.class);
    EasyMock.expect(manager.getStore()).andReturn(store).times(2);
    store.createDestinationSequence(ds);
    EasyMock.expectLastCall();
    store.removeDestinationSequence(id);
    EasyMock.expectLastCall();
    control.replay();
    destination.addSequence(ds);
    assertEquals(1, destination.getAllSequences().size());
    assertSame(ds, destination.getSequence(id));
    destination.removeSequence(ds);
    assertEquals(0, destination.getAllSequences().size());
}
Also used : Identifier(org.apache.cxf.ws.rm.v200702.Identifier) RMStore(org.apache.cxf.ws.rm.persistence.RMStore) Test(org.junit.Test)

Example 69 with Identifier

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

the class ManagedRMManagerTest method createTestDestinationSequence.

private DestinationSequence createTestDestinationSequence(Destination destination, String sid, EndpointReferenceType to, ProtocolVariation protocol, long[] acked) {
    Identifier identifier = RMUtils.getWSRMFactory().createIdentifier();
    identifier.setValue(sid);
    DestinationSequence ds = new DestinationSequence(identifier, to, null, protocol);
    ds.setDestination(destination);
    List<SequenceAcknowledgement.AcknowledgementRange> ranges = ds.getAcknowledgment().getAcknowledgementRange();
    for (int i = 0; i < acked.length; i += 2) {
        ranges.add(createAcknowledgementRange(acked[i], acked[i + 1]));
    }
    return ds;
}
Also used : Identifier(org.apache.cxf.ws.rm.v200702.Identifier) Endpoint(org.apache.cxf.endpoint.Endpoint)

Example 70 with Identifier

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

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