Search in sources :

Example 1 with RMAssertion

use of org.apache.cxf.ws.rmp.v200502.RMAssertion in project cxf by apache.

the class RMPolicyUtilities method getRMConfiguration.

/**
 * Returns an RMAssertion that is compatible with the default value and all RMAssertions pertaining to the
 * message (can never be null).
 *
 * @param rma the default value (non-<code>null</code>)
 * @param message the message
 * @return the compatible RMAssertion
 */
public static RMConfiguration getRMConfiguration(RMConfiguration defaultValue, Message message) {
    RMConfiguration compatible = defaultValue;
    Collection<AssertionInfo> ais = collectRMAssertions(message.get(AssertionInfoMap.class));
    for (AssertionInfo ai : ais) {
        if (ai.getAssertion() instanceof JaxbAssertion<?>) {
            RMAssertion rma = (RMAssertion) ((JaxbAssertion<?>) ai.getAssertion()).getData();
            compatible = intersect(rma, compatible);
        } else if (ai.getAssertion() instanceof PrimitiveAssertion) {
            PrimitiveAssertion assertion = (PrimitiveAssertion) ai.getAssertion();
            if (RM11Constants.WSRMP_NAMESPACE_URI.equals(assertion.getName().getNamespaceURI())) {
                compatible = intersect(assertion, compatible);
            }
        }
    }
    return compatible;
}
Also used : AssertionInfo(org.apache.cxf.ws.policy.AssertionInfo) RMAssertion(org.apache.cxf.ws.rmp.v200502.RMAssertion) PrimitiveAssertion(org.apache.neethi.builders.PrimitiveAssertion) RMConfiguration(org.apache.cxf.ws.rm.RMConfiguration) JaxbAssertion(org.apache.cxf.ws.policy.builder.jaxb.JaxbAssertion) AssertionInfoMap(org.apache.cxf.ws.policy.AssertionInfoMap)

Example 2 with RMAssertion

use of org.apache.cxf.ws.rmp.v200502.RMAssertion in project cxf by apache.

the class PolicyUtilsTest method testRMAssertionEquals.

@Test
public void testRMAssertionEquals() {
    RMAssertion a = new RMAssertion();
    assertTrue(RMPolicyUtilities.equals(a, a));
    RMAssertion b = new RMAssertion();
    assertTrue(RMPolicyUtilities.equals(a, b));
    InactivityTimeout iat = new RMAssertion.InactivityTimeout();
    iat.setMilliseconds(new Long(10));
    a.setInactivityTimeout(iat);
    assertTrue(!RMPolicyUtilities.equals(a, b));
    b.setInactivityTimeout(iat);
    assertTrue(RMPolicyUtilities.equals(a, b));
    ExponentialBackoff eb = new RMAssertion.ExponentialBackoff();
    a.setExponentialBackoff(eb);
    assertTrue(!RMPolicyUtilities.equals(a, b));
    b.setExponentialBackoff(eb);
    assertTrue(RMPolicyUtilities.equals(a, b));
}
Also used : RMAssertion(org.apache.cxf.ws.rmp.v200502.RMAssertion) InactivityTimeout(org.apache.cxf.ws.rmp.v200502.RMAssertion.InactivityTimeout) ExponentialBackoff(org.apache.cxf.ws.rmp.v200502.RMAssertion.ExponentialBackoff) Test(org.junit.Test)

Example 3 with RMAssertion

use of org.apache.cxf.ws.rmp.v200502.RMAssertion in project cxf by apache.

the class PolicyUtilsTest method testIntersect.

@Test
public void testIntersect() {
    RMAssertion rma = new RMAssertion();
    RMConfiguration cfg0 = new RMConfiguration();
    assertTrue(RMPolicyUtilities.equals(cfg0, RMPolicyUtilities.intersect(rma, cfg0)));
    InactivityTimeout aiat = new RMAssertion.InactivityTimeout();
    aiat.setMilliseconds(new Long(7200000));
    rma.setInactivityTimeout(aiat);
    cfg0.setInactivityTimeout(new Long(3600000));
    RMConfiguration cfg1 = RMPolicyUtilities.intersect(rma, cfg0);
    assertEquals(7200000L, cfg1.getInactivityTimeout().longValue());
    assertNull(cfg1.getBaseRetransmissionInterval());
    assertNull(cfg1.getAcknowledgementInterval());
    assertFalse(cfg1.isExponentialBackoff());
    BaseRetransmissionInterval abri = new RMAssertion.BaseRetransmissionInterval();
    abri.setMilliseconds(new Long(20000));
    rma.setBaseRetransmissionInterval(abri);
    cfg0.setBaseRetransmissionInterval(new Long(10000));
    cfg1 = RMPolicyUtilities.intersect(rma, cfg0);
    assertEquals(7200000L, cfg1.getInactivityTimeout().longValue());
    assertEquals(20000L, cfg1.getBaseRetransmissionInterval().longValue());
    assertNull(cfg1.getAcknowledgementInterval());
    assertFalse(cfg1.isExponentialBackoff());
    AcknowledgementInterval aai = new RMAssertion.AcknowledgementInterval();
    aai.setMilliseconds(new Long(2000));
    rma.setAcknowledgementInterval(aai);
    cfg1 = RMPolicyUtilities.intersect(rma, cfg0);
    assertEquals(7200000L, cfg1.getInactivityTimeout().longValue());
    assertEquals(20000L, cfg1.getBaseRetransmissionInterval().longValue());
    assertEquals(2000L, cfg1.getAcknowledgementInterval().longValue());
    assertFalse(cfg1.isExponentialBackoff());
    cfg0.setExponentialBackoff(true);
    cfg1 = RMPolicyUtilities.intersect(rma, cfg0);
    assertEquals(7200000L, cfg1.getInactivityTimeout().longValue());
    assertEquals(20000L, cfg1.getBaseRetransmissionInterval().longValue());
    assertEquals(2000L, cfg1.getAcknowledgementInterval().longValue());
    assertTrue(cfg1.isExponentialBackoff());
}
Also used : RMAssertion(org.apache.cxf.ws.rmp.v200502.RMAssertion) AcknowledgementInterval(org.apache.cxf.ws.rmp.v200502.RMAssertion.AcknowledgementInterval) BaseRetransmissionInterval(org.apache.cxf.ws.rmp.v200502.RMAssertion.BaseRetransmissionInterval) RMConfiguration(org.apache.cxf.ws.rm.RMConfiguration) InactivityTimeout(org.apache.cxf.ws.rmp.v200502.RMAssertion.InactivityTimeout) Test(org.junit.Test)

Example 4 with RMAssertion

use of org.apache.cxf.ws.rmp.v200502.RMAssertion 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 5 with RMAssertion

use of org.apache.cxf.ws.rmp.v200502.RMAssertion in project cxf by apache.

the class WSRM12ServerCycleTest method wsrm.

public static RMFeature wsrm(long brtxInterval, long ackInterval) {
    RMAssertion.BaseRetransmissionInterval baseRetransmissionInterval = new RMAssertion.BaseRetransmissionInterval();
    baseRetransmissionInterval.setMilliseconds(Long.valueOf(brtxInterval));
    RMAssertion.AcknowledgementInterval acknowledgementInterval = new RMAssertion.AcknowledgementInterval();
    acknowledgementInterval.setMilliseconds(Long.valueOf(ackInterval));
    RMAssertion rmAssertion = new RMAssertion();
    rmAssertion.setAcknowledgementInterval(acknowledgementInterval);
    rmAssertion.setBaseRetransmissionInterval(baseRetransmissionInterval);
    AcksPolicyType acksPolicy = new AcksPolicyType();
    acksPolicy.setIntraMessageThreshold(0);
    DestinationPolicyType destinationPolicy = new DestinationPolicyType();
    destinationPolicy.setAcksPolicy(acksPolicy);
    RMFeature feature = new RMFeature();
    feature.setRMAssertion(rmAssertion);
    feature.setDestinationPolicy(destinationPolicy);
    feature.setRMNamespace(RM11Constants.NAMESPACE_URI);
    return feature;
}
Also used : AcksPolicyType(org.apache.cxf.ws.rm.manager.AcksPolicyType) RMAssertion(org.apache.cxf.ws.rmp.v200502.RMAssertion) RMFeature(org.apache.cxf.ws.rm.feature.RMFeature) DestinationPolicyType(org.apache.cxf.ws.rm.manager.DestinationPolicyType)

Aggregations

RMAssertion (org.apache.cxf.ws.rmp.v200502.RMAssertion)5 RMConfiguration (org.apache.cxf.ws.rm.RMConfiguration)3 Test (org.junit.Test)3 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 InactivityTimeout (org.apache.cxf.ws.rmp.v200502.RMAssertion.InactivityTimeout)2 ArrayList (java.util.ArrayList)1 Message (org.apache.cxf.message.Message)1 RMFeature (org.apache.cxf.ws.rm.feature.RMFeature)1 AcksPolicyType (org.apache.cxf.ws.rm.manager.AcksPolicyType)1 DestinationPolicyType (org.apache.cxf.ws.rm.manager.DestinationPolicyType)1 AcknowledgementInterval (org.apache.cxf.ws.rmp.v200502.RMAssertion.AcknowledgementInterval)1 ExponentialBackoff (org.apache.cxf.ws.rmp.v200502.RMAssertion.ExponentialBackoff)1 PrimitiveAssertion (org.apache.neethi.builders.PrimitiveAssertion)1