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;
}
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));
}
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());
}
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();
}
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());
}
Aggregations