Search in sources :

Example 16 with Identifier

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

the class RMManagerTest method testDefaultSequenceIdentifierGenerator.

@Test
public void testDefaultSequenceIdentifierGenerator() {
    manager = new RMManager();
    assertNull(manager.getIdGenerator());
    SequenceIdentifierGenerator generator = manager.new DefaultSequenceIdentifierGenerator();
    manager.setIdGenerator(generator);
    assertSame(generator, manager.getIdGenerator());
    Identifier id1 = generator.generateSequenceIdentifier();
    assertNotNull(id1);
    assertNotNull(id1.getValue());
    Identifier id2 = generator.generateSequenceIdentifier();
    assertTrue(id1 != id2);
    assertTrue(!id1.getValue().equals(id2.getValue()));
    control.replay();
}
Also used : Identifier(org.apache.cxf.ws.rm.v200702.Identifier) Test(org.junit.Test)

Example 17 with Identifier

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

the class RMManagerTest method setUpRecoverReliableEndpoint.

void setUpRecoverReliableEndpoint(Endpoint endpoint, Conduit conduit, SourceSequence ss, DestinationSequence ds, RMMessage m) throws IOException {
    RMStore store = control.createMock(RMStore.class);
    RetransmissionQueue oqueue = control.createMock(RetransmissionQueue.class);
    RedeliveryQueue iqueue = control.createMock(RedeliveryQueue.class);
    manager.setStore(store);
    manager.setRetransmissionQueue(oqueue);
    manager.setRedeliveryQueue(iqueue);
    Collection<SourceSequence> sss = new ArrayList<>();
    if (null != ss) {
        sss.add(ss);
    }
    EasyMock.expect(store.getSourceSequences("{S}s.{P}p@cxf")).andReturn(sss);
    if (null == ss) {
        return;
    }
    Collection<DestinationSequence> dss = new ArrayList<>();
    if (null != ds) {
        dss.add(ds);
    }
    EasyMock.expect(store.getDestinationSequences("{S}s.{P}p@cxf")).andReturn(dss);
    if (null == ds) {
        return;
    }
    Collection<RMMessage> ms = new ArrayList<>();
    if (null != m) {
        ms.add(m);
    }
    Identifier id = new Identifier();
    id.setValue("S1");
    EasyMock.expect(ss.getIdentifier()).andReturn(id).times(null == m ? 1 : 2);
    EasyMock.expect(ss.getProtocol()).andReturn(ProtocolVariation.RM10WSA200408).anyTimes();
    EasyMock.expect(store.getMessages(id, true)).andReturn(ms);
    RMEndpoint rme = control.createMock(RMEndpoint.class);
    EasyMock.expect(manager.createReliableEndpoint(endpoint)).andReturn(rme);
    Source source = control.createMock(Source.class);
    EasyMock.expect(rme.getSource()).andReturn(source).anyTimes();
    Destination destination = control.createMock(Destination.class);
    EasyMock.expect(rme.getDestination()).andReturn(destination);
    destination.addSequence(ds, false);
    EasyMock.expectLastCall();
    Service service = control.createMock(Service.class);
    EasyMock.expect(endpoint.getService()).andReturn(service).anyTimes();
    Binding binding = control.createMock(Binding.class);
    EasyMock.expect(endpoint.getBinding()).andReturn(binding).anyTimes();
    EasyMock.expect(ss.isLastMessage()).andReturn(true).anyTimes();
    EasyMock.expect(ss.getCurrentMessageNr()).andReturn(new Long(10)).anyTimes();
    if (null == m) {
        return;
    }
    EasyMock.expect(m.getMessageNumber()).andReturn(new Long(10)).times(2);
    if (null == conduit) {
        EasyMock.expect(m.getTo()).andReturn("toAddress");
    }
    InputStream is = new ByteArrayInputStream(new byte[0]);
    CachedOutputStream cos = new CachedOutputStream();
    IOUtils.copy(is, cos);
    cos.flush();
    is.close();
    EasyMock.expect(m.getContent()).andReturn(cos).anyTimes();
    oqueue.addUnacknowledged(EasyMock.isA(Message.class));
    EasyMock.expectLastCall();
    oqueue.start();
    EasyMock.expectLastCall();
    iqueue.start();
    EasyMock.expectLastCall();
}
Also used : Binding(org.apache.cxf.binding.Binding) SoapBinding(org.apache.cxf.binding.soap.SoapBinding) Message(org.apache.cxf.message.Message) RMMessage(org.apache.cxf.ws.rm.persistence.RMMessage) RMMessage(org.apache.cxf.ws.rm.persistence.RMMessage) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) ArrayList(java.util.ArrayList) Service(org.apache.cxf.service.Service) RMStore(org.apache.cxf.ws.rm.persistence.RMStore) CachedOutputStream(org.apache.cxf.io.CachedOutputStream) Identifier(org.apache.cxf.ws.rm.v200702.Identifier) ByteArrayInputStream(java.io.ByteArrayInputStream)

Example 18 with Identifier

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

the class RMOutInterceptorTest method testHandleApplicationMessage.

@Test
public void testHandleApplicationMessage() throws NoSuchMethodException, SequenceFault, RMException {
    AddressingProperties maps = createMAPs("greetMe", "localhost:9000/GreeterPort", org.apache.cxf.ws.addressing.Names.WSA_NONE_ADDRESS);
    Method[] mocked = new Method[] { AbstractRMInterceptor.class.getDeclaredMethod("getManager", new Class[] {}), RMOutInterceptor.class.getDeclaredMethod("isRuntimeFault", new Class[] { Message.class }), RMOutInterceptor.class.getDeclaredMethod("addAcknowledgements", new Class[] { Destination.class, RMProperties.class, Identifier.class, AttributedURIType.class }) };
    RMOutInterceptor interceptor = EasyMock.createMockBuilder(RMOutInterceptor.class).addMockedMethods(mocked).createMock(control);
    RMManager manager = control.createMock(RMManager.class);
    EasyMock.expect(interceptor.getManager()).andReturn(manager).anyTimes();
    Message message = control.createMock(Message.class);
    EasyMock.expect(interceptor.isRuntimeFault(message)).andReturn(false).anyTimes();
    Exchange ex = control.createMock(Exchange.class);
    EasyMock.expect(message.getExchange()).andReturn(ex).anyTimes();
    EasyMock.expect(ex.getOutMessage()).andReturn(message).anyTimes();
    EasyMock.expect(ex.put("defer.uncorrelated.message.abort", Boolean.TRUE)).andReturn(null).anyTimes();
    EasyMock.expect(message.get(Message.REQUESTOR_ROLE)).andReturn(Boolean.TRUE).anyTimes();
    EasyMock.expect(message.get(JAXWSAConstants.ADDRESSING_PROPERTIES_OUTBOUND)).andReturn(maps).anyTimes();
    RMProperties rmpsOut = new RMProperties();
    EasyMock.expect(message.get(RMMessageConstants.RM_PROPERTIES_OUTBOUND)).andReturn(rmpsOut).anyTimes();
    InterceptorChain chain = control.createMock(InterceptorChain.class);
    EasyMock.expect(message.getInterceptorChain()).andReturn(chain).anyTimes();
    EasyMock.expectLastCall();
    RMEndpoint rme = control.createMock(RMEndpoint.class);
    RMConfiguration config = new RMConfiguration();
    config.setRMNamespace(RM10Constants.NAMESPACE_URI);
    config.setRM10AddressingNamespace(Names200408.WSA_NAMESPACE_NAME);
    EasyMock.expect(rme.getConfiguration()).andReturn(config).anyTimes();
    EasyMock.expect(manager.getEffectiveConfiguration(message)).andReturn(config).anyTimes();
    Source source = control.createMock(Source.class);
    EasyMock.expect(source.getReliableEndpoint()).andReturn(rme).anyTimes();
    EasyMock.expect(manager.getSource(message)).andReturn(source).anyTimes();
    Destination destination = control.createMock(Destination.class);
    EasyMock.expect(manager.getDestination(message)).andReturn(destination).anyTimes();
    SourceSequence sseq = control.createMock(SourceSequence.class);
    EasyMock.expect(sseq.getProtocol()).andReturn(ProtocolVariation.RM10WSA200408).anyTimes();
    EasyMock.expect(manager.getSequence((Identifier) EasyMock.isNull(), EasyMock.same(message), EasyMock.same(maps))).andReturn(sseq).anyTimes();
    EasyMock.expect(sseq.nextMessageNumber((Identifier) EasyMock.isNull(), (Long) EasyMock.eq(0L), EasyMock.eq(false))).andReturn(new Long(10)).anyTimes();
    EasyMock.expect(sseq.isLastMessage()).andReturn(false).anyTimes();
    interceptor.addAcknowledgements(EasyMock.same(destination), EasyMock.same(rmpsOut), (Identifier) EasyMock.isNull(), EasyMock.isA(AttributedURIType.class));
    EasyMock.expectLastCall();
    Identifier sid = control.createMock(Identifier.class);
    EasyMock.expect(sseq.getIdentifier()).andReturn(sid).anyTimes();
    EasyMock.expect(sseq.getCurrentMessageNr()).andReturn(new Long(10)).anyTimes();
    control.replay();
    interceptor.handle(message);
    control.verify();
}
Also used : Message(org.apache.cxf.message.Message) AttributedURIType(org.apache.cxf.ws.addressing.AttributedURIType) Method(java.lang.reflect.Method) Exchange(org.apache.cxf.message.Exchange) InterceptorChain(org.apache.cxf.interceptor.InterceptorChain) Identifier(org.apache.cxf.ws.rm.v200702.Identifier) AddressingProperties(org.apache.cxf.ws.addressing.AddressingProperties) Test(org.junit.Test)

Example 19 with Identifier

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

the class ServantTest method createTestTerminateSequenceMessage.

private static Message createTestTerminateSequenceMessage(String sidstr, ProtocolVariation protocol) {
    Message message = new MessageImpl();
    Exchange exchange = new ExchangeImpl();
    exchange.setInMessage(message);
    message.put(Message.REQUESTOR_ROLE, Boolean.FALSE);
    AddressingProperties maps = new AddressingProperties();
    String msgId = "urn:uuid:12345-" + Math.random();
    AttributedURIType id = ContextUtils.getAttributedURI(msgId);
    maps.setMessageID(id);
    maps.setAction(ContextUtils.getAttributedURI(RM10Constants.INSTANCE.getTerminateSequenceAction()));
    maps.setTo(ContextUtils.getAttributedURI(SERVICE_URL));
    maps.setReplyTo(RMUtils.createReference(DECOUPLED_URL));
    message.put(JAXWSAConstants.ADDRESSING_PROPERTIES_INBOUND, maps);
    TerminateSequenceType ts = new TerminateSequenceType();
    Identifier sid = new Identifier();
    sid.setValue(sidstr);
    ts.setIdentifier(sid);
    Object tst = ProtocolVariation.RM10WSA200408.getWSRMNamespace().equals(protocol.getWSRMNamespace()) ? ts : ProtocolVariation.RM10WSA200408.getCodec().convertReceivedTerminateSequence(ts);
    MessageContentsList contents = new MessageContentsList();
    contents.add(tst);
    message.setContent(List.class, contents);
    RMContextUtils.setProtocolVariation(message, protocol);
    return message;
}
Also used : Exchange(org.apache.cxf.message.Exchange) Identifier(org.apache.cxf.ws.rm.v200502.Identifier) Message(org.apache.cxf.message.Message) MessageContentsList(org.apache.cxf.message.MessageContentsList) AttributedURIType(org.apache.cxf.ws.addressing.AttributedURIType) TerminateSequenceType(org.apache.cxf.ws.rm.v200502.TerminateSequenceType) AddressingProperties(org.apache.cxf.ws.addressing.AddressingProperties) MessageImpl(org.apache.cxf.message.MessageImpl) ExchangeImpl(org.apache.cxf.message.ExchangeImpl)

Example 20 with Identifier

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

the class ServantTest method createTestCloseSequenceMessage.

private static Message createTestCloseSequenceMessage(String sidstr) {
    Message message = new MessageImpl();
    Exchange exchange = new ExchangeImpl();
    exchange.setInMessage(message);
    message.put(Message.REQUESTOR_ROLE, Boolean.FALSE);
    AddressingProperties maps = new AddressingProperties();
    String msgId = "urn:uuid:12345-" + Math.random();
    AttributedURIType id = ContextUtils.getAttributedURI(msgId);
    maps.setMessageID(id);
    maps.setAction(ContextUtils.getAttributedURI(RM10Constants.INSTANCE.getTerminateSequenceAction()));
    maps.setTo(ContextUtils.getAttributedURI(SERVICE_URL));
    maps.setReplyTo(RMUtils.createReference(DECOUPLED_URL));
    message.put(JAXWSAConstants.ADDRESSING_PROPERTIES_INBOUND, maps);
    CloseSequenceType cs = new CloseSequenceType();
    org.apache.cxf.ws.rm.v200702.Identifier sid = new org.apache.cxf.ws.rm.v200702.Identifier();
    sid.setValue(sidstr);
    cs.setIdentifier(sid);
    MessageContentsList contents = new MessageContentsList();
    contents.add(cs);
    message.setContent(List.class, contents);
    RMContextUtils.setProtocolVariation(message, ProtocolVariation.RM11WSA200508);
    return message;
}
Also used : Message(org.apache.cxf.message.Message) MessageContentsList(org.apache.cxf.message.MessageContentsList) AttributedURIType(org.apache.cxf.ws.addressing.AttributedURIType) Exchange(org.apache.cxf.message.Exchange) Identifier(org.apache.cxf.ws.rm.v200502.Identifier) CloseSequenceType(org.apache.cxf.ws.rm.v200702.CloseSequenceType) AddressingProperties(org.apache.cxf.ws.addressing.AddressingProperties) MessageImpl(org.apache.cxf.message.MessageImpl) 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