Search in sources :

Example 6 with ClientPolicyCalculator

use of org.apache.cxf.transport.http.policy.impl.ClientPolicyCalculator in project cxf by apache.

the class HTTPConduit method updateClientPolicy.

/**
 * updates the HTTPClientPolicy that is compatible with the assertions
 * included in the service, endpoint, operation and message policy subjects
 * if a PolicyDataEngine is installed
 *
 * wsdl extensors are superseded by policies which in
 * turn are superseded by injection
 */
private void updateClientPolicy(Message m) {
    if (!clientSidePolicyCalced) {
        PolicyDataEngine policyEngine = bus.getExtension(PolicyDataEngine.class);
        if (policyEngine != null && endpointInfo.getService() != null) {
            clientSidePolicy = policyEngine.getClientEndpointPolicy(m, endpointInfo, this, new ClientPolicyCalculator());
            if (clientSidePolicy != null) {
                // make sure we aren't added twice
                clientSidePolicy.removePropertyChangeListener(this);
                clientSidePolicy.addPropertyChangeListener(this);
            }
        }
    }
    clientSidePolicyCalced = true;
}
Also used : PolicyDataEngine(org.apache.cxf.policy.PolicyDataEngine) ClientPolicyCalculator(org.apache.cxf.transport.http.policy.impl.ClientPolicyCalculator)

Example 7 with ClientPolicyCalculator

use of org.apache.cxf.transport.http.policy.impl.ClientPolicyCalculator in project cxf by apache.

the class ClientPolicyCalculatorTest method testEqualClientPolicies.

@Test
public void testEqualClientPolicies() {
    ClientPolicyCalculator calc = new ClientPolicyCalculator();
    HTTPClientPolicy p1 = new HTTPClientPolicy();
    assertTrue(calc.equals(p1, p1));
    HTTPClientPolicy p2 = new HTTPClientPolicy();
    assertTrue(calc.equals(p1, p2));
    p1.setDecoupledEndpoint("http://localhost:8080/decoupled");
    assertTrue(!calc.equals(p1, p2));
    p2.setDecoupledEndpoint("http://localhost:8080/decoupled");
    assertTrue(calc.equals(p1, p2));
    p1.setReceiveTimeout(10000L);
    assertTrue(!calc.equals(p1, p2));
}
Also used : HTTPClientPolicy(org.apache.cxf.transports.http.configuration.HTTPClientPolicy) ClientPolicyCalculator(org.apache.cxf.transport.http.policy.impl.ClientPolicyCalculator) Test(org.junit.Test)

Example 8 with ClientPolicyCalculator

use of org.apache.cxf.transport.http.policy.impl.ClientPolicyCalculator in project cxf by apache.

the class ClientPolicyCalculatorTest method testIntersectClientPolicies.

@Test
public void testIntersectClientPolicies() {
    ClientPolicyCalculator calc = new ClientPolicyCalculator();
    HTTPClientPolicy p1 = new HTTPClientPolicy();
    HTTPClientPolicy p2 = new HTTPClientPolicy();
    HTTPClientPolicy p = null;
    p1.setBrowserType("browser");
    p = calc.intersect(p1, p2);
    assertEquals("browser", p.getBrowserType());
    p1.setBrowserType(null);
    p1.setConnectionTimeout(10000L);
    p = calc.intersect(p1, p2);
    assertEquals(10000L, p.getConnectionTimeout());
    p1.setAllowChunking(false);
    p2.setAllowChunking(false);
    p = calc.intersect(p1, p2);
    assertTrue(!p.isAllowChunking());
}
Also used : HTTPClientPolicy(org.apache.cxf.transports.http.configuration.HTTPClientPolicy) ClientPolicyCalculator(org.apache.cxf.transport.http.policy.impl.ClientPolicyCalculator) Test(org.junit.Test)

Example 9 with ClientPolicyCalculator

use of org.apache.cxf.transport.http.policy.impl.ClientPolicyCalculator 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 10 with ClientPolicyCalculator

use of org.apache.cxf.transport.http.policy.impl.ClientPolicyCalculator 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

ClientPolicyCalculator (org.apache.cxf.transport.http.policy.impl.ClientPolicyCalculator)10 HTTPClientPolicy (org.apache.cxf.transports.http.configuration.HTTPClientPolicy)6 PolicyDataEngine (org.apache.cxf.policy.PolicyDataEngine)5 Test (org.junit.Test)5 ArrayList (java.util.ArrayList)2 Message (org.apache.cxf.message.Message)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 ServerPolicyCalculator (org.apache.cxf.transport.http.policy.impl.ServerPolicyCalculator)1 AssertionInfo (org.apache.cxf.ws.policy.AssertionInfo)1 JaxbAssertion (org.apache.cxf.ws.policy.builder.jaxb.JaxbAssertion)1 Assertion (org.apache.neethi.Assertion)1