Search in sources :

Example 6 with RMConfiguration

use of org.apache.cxf.ws.rm.RMConfiguration in project cxf by apache.

the class PolicyUtilsTest method testGetRMConfiguration.

@Test
public void testGetRMConfiguration() {
    RMConfiguration cfg = new RMConfiguration();
    cfg.setBaseRetransmissionInterval(new Long(3000));
    cfg.setExponentialBackoff(true);
    Message message = control.createMock(Message.class);
    EasyMock.expect(message.get(AssertionInfoMap.class)).andReturn(null);
    control.replay();
    assertSame(cfg, RMPolicyUtilities.getRMConfiguration(cfg, message));
    control.verify();
    control.reset();
    AssertionInfoMap aim = control.createMock(AssertionInfoMap.class);
    EasyMock.expect(message.get(AssertionInfoMap.class)).andReturn(aim);
    Collection<AssertionInfo> ais = new ArrayList<>();
    EasyMock.expect(aim.get(RM10Constants.RMASSERTION_QNAME)).andReturn(ais);
    control.replay();
    assertSame(cfg, RMPolicyUtilities.getRMConfiguration(cfg, message));
    control.verify();
    control.reset();
    RMAssertion b = new RMAssertion();
    BaseRetransmissionInterval bbri = new RMAssertion.BaseRetransmissionInterval();
    bbri.setMilliseconds(new Long(2000));
    b.setBaseRetransmissionInterval(bbri);
    JaxbAssertion<RMAssertion> assertion = new JaxbAssertion<RMAssertion>();
    assertion.setName(RM10Constants.RMASSERTION_QNAME);
    assertion.setData(b);
    AssertionInfo ai = new AssertionInfo(assertion);
    ais.add(ai);
    EasyMock.expect(message.get(AssertionInfoMap.class)).andReturn(aim);
    EasyMock.expect(aim.get(RM10Constants.RMASSERTION_QNAME)).andReturn(ais);
    control.replay();
    RMConfiguration cfg1 = RMPolicyUtilities.getRMConfiguration(cfg, message);
    assertNull(cfg1.getAcknowledgementInterval());
    assertNull(cfg1.getInactivityTimeout());
    assertEquals(2000L, cfg1.getBaseRetransmissionInterval().longValue());
    assertTrue(cfg1.isExponentialBackoff());
    control.verify();
}
Also used : AssertionInfo(org.apache.cxf.ws.policy.AssertionInfo) Message(org.apache.cxf.message.Message) RMAssertion(org.apache.cxf.ws.rmp.v200502.RMAssertion) BaseRetransmissionInterval(org.apache.cxf.ws.rmp.v200502.RMAssertion.BaseRetransmissionInterval) ArrayList(java.util.ArrayList) RMConfiguration(org.apache.cxf.ws.rm.RMConfiguration) JaxbAssertion(org.apache.cxf.ws.policy.builder.jaxb.JaxbAssertion) AssertionInfoMap(org.apache.cxf.ws.policy.AssertionInfoMap) Test(org.junit.Test)

Example 7 with RMConfiguration

use of org.apache.cxf.ws.rm.RMConfiguration in project cxf by apache.

the class RetransmissionQueueImplTest method setupMessagePolicies.

private void setupMessagePolicies(Message message) {
    RMConfiguration cfg = new RMConfiguration();
    EasyMock.expect(manager.getEffectiveConfiguration(message)).andReturn(cfg);
    cfg.setBaseRetransmissionInterval(new Long(5000));
    cfg.setExponentialBackoff(true);
}
Also used : RMConfiguration(org.apache.cxf.ws.rm.RMConfiguration)

Example 8 with RMConfiguration

use of org.apache.cxf.ws.rm.RMConfiguration in project cxf by apache.

the class RMSoapInInterceptor method decodeHeaders.

public void decodeHeaders(SoapMessage message, List<Header> headers, RMProperties rmps) {
    try {
        Collection<SequenceAcknowledgement> acks = new ArrayList<>();
        Collection<AckRequestedType> requested = new ArrayList<>();
        String rmUri = null;
        EncoderDecoder codec = null;
        Iterator<Header> iter = headers.iterator();
        while (iter.hasNext()) {
            Object node = iter.next().getObject();
            if (node instanceof Element) {
                Element elem = (Element) node;
                if (Node.ELEMENT_NODE != elem.getNodeType()) {
                    continue;
                }
                String ns = elem.getNamespaceURI();
                if (rmUri == null && (RM10Constants.NAMESPACE_URI.equals(ns) || RM11Constants.NAMESPACE_URI.equals(ns))) {
                    LOG.log(Level.FINE, "set RM namespace {0}", ns);
                    rmUri = ns;
                    rmps.exposeAs(rmUri);
                }
                if (rmUri != null && rmUri.equals(ns)) {
                    if (codec == null) {
                        String wsauri = null;
                        AddressingProperties maps = ContextUtils.retrieveMAPs(message, false, false, false);
                        if (maps == null) {
                            RMConfiguration config = getManager(message).getEffectiveConfiguration(message);
                            wsauri = config.getAddressingNamespace();
                        } else {
                            wsauri = maps.getNamespaceURI();
                        }
                        ProtocolVariation protocol = ProtocolVariation.findVariant(rmUri, wsauri);
                        if (protocol == null) {
                            LOG.log(Level.WARNING, "NAMESPACE_ERROR_MSG", wsauri);
                            break;
                        }
                        codec = protocol.getCodec();
                    }
                    String localName = elem.getLocalName();
                    LOG.log(Level.FINE, "decoding RM header {0}", localName);
                    if (RMConstants.SEQUENCE_NAME.equals(localName)) {
                        rmps.setSequence(codec.decodeSequenceType(elem));
                        rmps.setCloseSequence(codec.decodeSequenceTypeCloseSequence(elem));
                    } else if (RMConstants.SEQUENCE_ACK_NAME.equals(localName)) {
                        acks.add(codec.decodeSequenceAcknowledgement(elem));
                    } else if (RMConstants.ACK_REQUESTED_NAME.equals(localName)) {
                        requested.add(codec.decodeAckRequestedType(elem));
                    }
                }
            }
        }
        if (!acks.isEmpty()) {
            rmps.setAcks(acks);
        }
        if (!requested.isEmpty()) {
            rmps.setAcksRequested(requested);
        }
    } catch (JAXBException ex) {
        LOG.log(Level.WARNING, "SOAP_HEADER_DECODE_FAILURE_MSG", ex);
    }
}
Also used : EncoderDecoder(org.apache.cxf.ws.rm.EncoderDecoder) Element(org.w3c.dom.Element) JAXBException(javax.xml.bind.JAXBException) ArrayList(java.util.ArrayList) RMConfiguration(org.apache.cxf.ws.rm.RMConfiguration) Header(org.apache.cxf.headers.Header) AckRequestedType(org.apache.cxf.ws.rm.v200702.AckRequestedType) AddressingProperties(org.apache.cxf.ws.addressing.AddressingProperties) SequenceAcknowledgement(org.apache.cxf.ws.rm.v200702.SequenceAcknowledgement) ProtocolVariation(org.apache.cxf.ws.rm.ProtocolVariation)

Aggregations

RMConfiguration (org.apache.cxf.ws.rm.RMConfiguration)8 RMAssertion (org.apache.cxf.ws.rmp.v200502.RMAssertion)3 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 AssertionInfo (org.apache.cxf.ws.policy.AssertionInfo)2 AssertionInfoMap (org.apache.cxf.ws.policy.AssertionInfoMap)2 JaxbAssertion (org.apache.cxf.ws.policy.builder.jaxb.JaxbAssertion)2 BaseRetransmissionInterval (org.apache.cxf.ws.rmp.v200502.RMAssertion.BaseRetransmissionInterval)2 JAXBException (javax.xml.bind.JAXBException)1 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)1 GreeterService (org.apache.cxf.greeter_control.GreeterService)1 Header (org.apache.cxf.headers.Header)1 Message (org.apache.cxf.message.Message)1 AddressingProperties (org.apache.cxf.ws.addressing.AddressingProperties)1 EncoderDecoder (org.apache.cxf.ws.rm.EncoderDecoder)1 ProtocolVariation (org.apache.cxf.ws.rm.ProtocolVariation)1 RMManager (org.apache.cxf.ws.rm.RMManager)1 AckRequestedType (org.apache.cxf.ws.rm.v200702.AckRequestedType)1 SequenceAcknowledgement (org.apache.cxf.ws.rm.v200702.SequenceAcknowledgement)1 AcknowledgementInterval (org.apache.cxf.ws.rmp.v200502.RMAssertion.AcknowledgementInterval)1