Search in sources :

Example 1 with JaxbAssertion

use of org.apache.cxf.ws.policy.builder.jaxb.JaxbAssertion in project cxf by apache.

the class HTTPClientAssertionBuilderTest method testBuildAssertion.

@Test
public void testBuildAssertion() throws Exception {
    HTTPClientAssertionBuilder ab = new HTTPClientAssertionBuilder();
    Assertion a = ab.buildAssertion();
    assertTrue(a instanceof JaxbAssertion);
    assertTrue(a instanceof HTTPClientAssertionBuilder.HTTPClientPolicyAssertion);
    assertEquals(new ClientPolicyCalculator().getDataClassName(), a.getName());
    assertTrue(!a.isOptional());
}
Also used : JaxbAssertion(org.apache.cxf.ws.policy.builder.jaxb.JaxbAssertion) Assertion(org.apache.neethi.Assertion) JaxbAssertion(org.apache.cxf.ws.policy.builder.jaxb.JaxbAssertion) ClientPolicyCalculator(org.apache.cxf.transport.http.policy.impl.ClientPolicyCalculator) Test(org.junit.Test)

Example 2 with JaxbAssertion

use of org.apache.cxf.ws.policy.builder.jaxb.JaxbAssertion 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 3 with JaxbAssertion

use of org.apache.cxf.ws.policy.builder.jaxb.JaxbAssertion 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 4 with JaxbAssertion

use of org.apache.cxf.ws.policy.builder.jaxb.JaxbAssertion in project cxf by apache.

the class HTTPServerAssertionBuilderTest method testBuildAssertion.

@Test
public void testBuildAssertion() throws Exception {
    HTTPServerAssertionBuilder ab = new HTTPServerAssertionBuilder();
    Assertion a = ab.buildAssertion();
    assertTrue(a instanceof JaxbAssertion);
    assertTrue(a instanceof HTTPServerAssertionBuilder.HTTPServerPolicyAssertion);
    assertEquals(new ServerPolicyCalculator().getDataClassName(), a.getName());
    assertTrue(!a.isOptional());
}
Also used : JaxbAssertion(org.apache.cxf.ws.policy.builder.jaxb.JaxbAssertion) Assertion(org.apache.neethi.Assertion) JaxbAssertion(org.apache.cxf.ws.policy.builder.jaxb.JaxbAssertion) ServerPolicyCalculator(org.apache.cxf.transport.http.policy.impl.ServerPolicyCalculator) Test(org.junit.Test)

Aggregations

JaxbAssertion (org.apache.cxf.ws.policy.builder.jaxb.JaxbAssertion)4 Test (org.junit.Test)3 AssertionInfo (org.apache.cxf.ws.policy.AssertionInfo)2 AssertionInfoMap (org.apache.cxf.ws.policy.AssertionInfoMap)2 RMConfiguration (org.apache.cxf.ws.rm.RMConfiguration)2 RMAssertion (org.apache.cxf.ws.rmp.v200502.RMAssertion)2 Assertion (org.apache.neethi.Assertion)2 ArrayList (java.util.ArrayList)1 Message (org.apache.cxf.message.Message)1 ClientPolicyCalculator (org.apache.cxf.transport.http.policy.impl.ClientPolicyCalculator)1 ServerPolicyCalculator (org.apache.cxf.transport.http.policy.impl.ServerPolicyCalculator)1 BaseRetransmissionInterval (org.apache.cxf.ws.rmp.v200502.RMAssertion.BaseRetransmissionInterval)1 PrimitiveAssertion (org.apache.neethi.builders.PrimitiveAssertion)1