use of org.apache.cxf.transport.http.policy.impl.ServerPolicyCalculator in project cxf by apache.
the class PolicyUtilsTest method testAssertPolicyNoop.
void testAssertPolicyNoop(boolean isRequestor) {
PolicyDataEngine pde = new PolicyDataEngineImpl(null);
Message message = control.createMock(Message.class);
EasyMock.expect(message.get(AssertionInfoMap.class)).andReturn(null);
control.replay();
pde.assertMessage(message, null, new ClientPolicyCalculator());
control.verify();
control.reset();
Collection<PolicyAssertion> as = new ArrayList<>();
AssertionInfoMap aim = new AssertionInfoMap(as);
EasyMock.expect(message.get(AssertionInfoMap.class)).andReturn(aim);
control.replay();
if (isRequestor) {
pde.assertMessage(message, null, new ClientPolicyCalculator());
} else {
pde.assertMessage(message, null, new ServerPolicyCalculator());
}
control.verify();
}
use of org.apache.cxf.transport.http.policy.impl.ServerPolicyCalculator in project cxf by apache.
the class ServerPolicyCalculatorTest method testEqualServerPolicies.
@Test
public void testEqualServerPolicies() {
ServerPolicyCalculator spc = new ServerPolicyCalculator();
HTTPServerPolicy p1 = new HTTPServerPolicy();
assertTrue(spc.equals(p1, p1));
HTTPServerPolicy p2 = new HTTPServerPolicy();
assertTrue(spc.equals(p1, p2));
p1.setContentEncoding("encoding");
assertTrue(!spc.equals(p1, p2));
p2.setContentEncoding("encoding");
assertTrue(spc.equals(p1, p2));
p1.setSuppressClientSendErrors(true);
assertTrue(!spc.equals(p1, p2));
}
use of org.apache.cxf.transport.http.policy.impl.ServerPolicyCalculator in project cxf by apache.
the class ServerPolicyCalculatorTest method testCompatibleServerPolicies.
@Test
public void testCompatibleServerPolicies() {
ServerPolicyCalculator spc = new ServerPolicyCalculator();
HTTPServerPolicy p1 = new HTTPServerPolicy();
assertTrue("Policy is not compatible with itself.", spc.compatible(p1, p1));
HTTPServerPolicy p2 = new HTTPServerPolicy();
assertTrue("Policies are not compatible.", spc.compatible(p1, p2));
p1.setServerType("server");
assertTrue("Policies are not compatible.", spc.compatible(p1, p2));
p1.setServerType(null);
p1.setReceiveTimeout(10000);
assertTrue("Policies are not compatible.", spc.compatible(p1, p2));
p1.setSuppressClientSendErrors(false);
assertTrue("Policies are compatible.", spc.compatible(p1, p2));
p1.setSuppressClientSendErrors(true);
assertTrue("Policies are compatible.", !spc.compatible(p1, p2));
p2.setSuppressClientSendErrors(true);
assertTrue("Policies are compatible.", spc.compatible(p1, p2));
}
use of org.apache.cxf.transport.http.policy.impl.ServerPolicyCalculator in project cxf by apache.
the class ServerPolicyCalculatorTest method testIntersectServerPolicies.
@Test
public void testIntersectServerPolicies() {
ServerPolicyCalculator spc = new ServerPolicyCalculator();
HTTPServerPolicy p1 = new HTTPServerPolicy();
HTTPServerPolicy p2 = new HTTPServerPolicy();
HTTPServerPolicy p = null;
p1.setServerType("server");
p = spc.intersect(p1, p2);
assertEquals("server", p.getServerType());
p1.setServerType(null);
p1.setReceiveTimeout(10000L);
p = spc.intersect(p1, p2);
assertEquals(10000L, p.getReceiveTimeout());
p1.setSuppressClientSendErrors(true);
p2.setSuppressClientSendErrors(true);
p = spc.intersect(p1, p2);
assertTrue(p.isSuppressClientSendErrors());
}
use of org.apache.cxf.transport.http.policy.impl.ServerPolicyCalculator in project cxf by apache.
the class AbstractHTTPDestination method calcServerPolicyInternal.
private synchronized HTTPServerPolicy calcServerPolicyInternal(Message m) {
HTTPServerPolicy sp = serverPolicy;
if (!serverPolicyCalced) {
PolicyDataEngine pde = bus.getExtension(PolicyDataEngine.class);
if (pde != null) {
sp = pde.getServerEndpointPolicy(m, endpointInfo, this, new ServerPolicyCalculator());
}
if (null == sp) {
sp = endpointInfo.getTraversedExtensor(new HTTPServerPolicy(), HTTPServerPolicy.class);
}
serverPolicy = sp;
serverPolicyCalced = true;
}
return sp;
}
Aggregations