Search in sources :

Example 6 with PolicyDataEngine

use of org.apache.cxf.policy.PolicyDataEngine in project cxf by apache.

the class PolicyUtilsTest method testAssertClientPolicy.

void testAssertClientPolicy(boolean outbound) {
    Message message = control.createMock(Message.class);
    HTTPClientPolicy ep = new HTTPClientPolicy();
    HTTPClientPolicy cmp = new HTTPClientPolicy();
    cmp.setConnectionTimeout(60000L);
    HTTPClientPolicy icmp = new HTTPClientPolicy();
    icmp.setAllowChunking(false);
    AssertionInfo eai = getClientPolicyAssertionInfo(ep);
    AssertionInfo cmai = getClientPolicyAssertionInfo(cmp);
    AssertionInfo icmai = getClientPolicyAssertionInfo(icmp);
    AssertionInfoMap aim = new AssertionInfoMap(CastUtils.cast(Collections.EMPTY_LIST, PolicyAssertion.class));
    Collection<AssertionInfo> ais = new ArrayList<>();
    ais.add(eai);
    ais.add(cmai);
    ais.add(icmai);
    aim.put(new ClientPolicyCalculator().getDataClassName(), ais);
    EasyMock.expect(message.get(AssertionInfoMap.class)).andReturn(aim);
    Exchange ex = control.createMock(Exchange.class);
    EasyMock.expect(message.getExchange()).andReturn(ex).atLeastOnce();
    EasyMock.expect(ex.getOutMessage()).andReturn(outbound ? message : null).atLeastOnce();
    if (!outbound) {
        EasyMock.expect(ex.getOutFaultMessage()).andReturn(null).atLeastOnce();
    }
    control.replay();
    PolicyDataEngine pde = new PolicyDataEngineImpl(null);
    pde.assertMessage(message, ep, new ClientPolicyCalculator());
    assertTrue(eai.isAsserted());
    assertTrue(cmai.isAsserted());
    assertTrue(icmai.isAsserted());
    control.verify();
}
Also used : Exchange(org.apache.cxf.message.Exchange) PolicyAssertion(org.apache.cxf.ws.policy.PolicyAssertion) AssertionInfo(org.apache.cxf.ws.policy.AssertionInfo) Message(org.apache.cxf.message.Message) HTTPClientPolicy(org.apache.cxf.transports.http.configuration.HTTPClientPolicy) ArrayList(java.util.ArrayList) PolicyDataEngine(org.apache.cxf.policy.PolicyDataEngine) PolicyDataEngineImpl(org.apache.cxf.ws.policy.PolicyDataEngineImpl) AssertionInfoMap(org.apache.cxf.ws.policy.AssertionInfoMap) ClientPolicyCalculator(org.apache.cxf.transport.http.policy.impl.ClientPolicyCalculator)

Example 7 with PolicyDataEngine

use of org.apache.cxf.policy.PolicyDataEngine in project cxf by apache.

the class HTTPConduit method assertMessage.

public void assertMessage(Message message) {
    PolicyDataEngine policyDataEngine = bus.getExtension(PolicyDataEngine.class);
    policyDataEngine.assertMessage(message, getClient(), new ClientPolicyCalculator());
}
Also used : PolicyDataEngine(org.apache.cxf.policy.PolicyDataEngine) ClientPolicyCalculator(org.apache.cxf.transport.http.policy.impl.ClientPolicyCalculator)

Aggregations

PolicyDataEngine (org.apache.cxf.policy.PolicyDataEngine)7 ClientPolicyCalculator (org.apache.cxf.transport.http.policy.impl.ClientPolicyCalculator)5 ServerPolicyCalculator (org.apache.cxf.transport.http.policy.impl.ServerPolicyCalculator)3 ArrayList (java.util.ArrayList)2 Message (org.apache.cxf.message.Message)2 HTTPClientPolicy (org.apache.cxf.transports.http.configuration.HTTPClientPolicy)2 AssertionInfoMap (org.apache.cxf.ws.policy.AssertionInfoMap)2 PolicyAssertion (org.apache.cxf.ws.policy.PolicyAssertion)2 PolicyDataEngineImpl (org.apache.cxf.ws.policy.PolicyDataEngineImpl)2 Exchange (org.apache.cxf.message.Exchange)1 HTTPServerPolicy (org.apache.cxf.transports.http.configuration.HTTPServerPolicy)1 AssertionInfo (org.apache.cxf.ws.policy.AssertionInfo)1