Search in sources :

Example 11 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");
    assertFalse(calc.equals(p1, p2));
    p2.setDecoupledEndpoint("http://localhost:8080/decoupled");
    assertTrue(calc.equals(p1, p2));
    p1.setReceiveTimeout(10000L);
    assertFalse(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 12 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() {
    ThreadLocalRandom random = ThreadLocalRandom.current();
    ClientPolicyCalculator calc = new ClientPolicyCalculator();
    HTTPClientPolicy p1 = new HTTPClientPolicy();
    HTTPClientPolicy p2 = new HTTPClientPolicy();
    p1.setBrowserType("browser");
    HTTPClientPolicy p = calc.intersect(p1, p2);
    assertEquals("browser", p.getBrowserType());
    p1.setBrowserType(null);
    long connectionRequestTimeout = random.nextLong(0, 10000);
    p1.setConnectionRequestTimeout(connectionRequestTimeout);
    p = calc.intersect(p1, p2);
    assertEquals(connectionRequestTimeout, p.getConnectionRequestTimeout());
    long receiveTimeout = random.nextLong(0, 10000);
    p1.setReceiveTimeout(receiveTimeout);
    p = calc.intersect(p1, p2);
    assertEquals(receiveTimeout, p.getReceiveTimeout());
    long connectionTimeout = random.nextLong(0, 10000);
    p1.setConnectionTimeout(connectionTimeout);
    p = calc.intersect(p1, p2);
    assertEquals(connectionTimeout, p.getConnectionTimeout());
    p1.setAllowChunking(false);
    p2.setAllowChunking(false);
    p = calc.intersect(p1, p2);
    assertFalse(p.isAllowChunking());
}
Also used : HTTPClientPolicy(org.apache.cxf.transports.http.configuration.HTTPClientPolicy) ThreadLocalRandom(java.util.concurrent.ThreadLocalRandom) ClientPolicyCalculator(org.apache.cxf.transport.http.policy.impl.ClientPolicyCalculator) Test(org.junit.Test)

Example 13 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)13 PolicyDataEngine (org.apache.cxf.policy.PolicyDataEngine)8 HTTPClientPolicy (org.apache.cxf.transports.http.configuration.HTTPClientPolicy)7 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 ThreadLocalRandom (java.util.concurrent.ThreadLocalRandom)1 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