use of org.apache.cxf.ws.policy.PolicyDataEngineImpl 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.ws.policy.PolicyDataEngineImpl in project cxf by apache.
the class PolicyUtilsTest method testAssertServerPolicy.
void testAssertServerPolicy(boolean outbound) {
Message message = control.createMock(Message.class);
HTTPServerPolicy ep = new HTTPServerPolicy();
HTTPServerPolicy mp = new HTTPServerPolicy();
HTTPServerPolicy cmp = new HTTPServerPolicy();
cmp.setReceiveTimeout(60000L);
HTTPServerPolicy icmp = new HTTPServerPolicy();
icmp.setSuppressClientSendErrors(true);
AssertionInfo eai = getServerPolicyAssertionInfo(ep);
AssertionInfo mai = getServerPolicyAssertionInfo(mp);
AssertionInfo cmai = getServerPolicyAssertionInfo(cmp);
AssertionInfo icmai = getServerPolicyAssertionInfo(icmp);
Collection<AssertionInfo> ais = new ArrayList<>();
ais.add(eai);
ais.add(mai);
ais.add(cmai);
ais.add(icmai);
AssertionInfoMap aim = new AssertionInfoMap(CastUtils.cast(Collections.EMPTY_LIST, PolicyAssertion.class));
aim.put(new ServerPolicyCalculator().getDataClassName(), ais);
EasyMock.expect(message.get(AssertionInfoMap.class)).andReturn(aim).atLeastOnce();
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();
new PolicyDataEngineImpl(null).assertMessage(message, ep, new ServerPolicyCalculator());
assertTrue(eai.isAsserted());
assertTrue(mai.isAsserted());
assertTrue(outbound ? cmai.isAsserted() : !cmai.isAsserted());
assertTrue(outbound ? icmai.isAsserted() : !icmai.isAsserted());
control.verify();
}
use of org.apache.cxf.ws.policy.PolicyDataEngineImpl 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();
}
Aggregations