Search in sources :

Example 6 with ServerPolicyCalculator

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

the class AbstractHTTPDestination method assertMessage.

public void assertMessage(Message message) {
    PolicyDataEngine pde = bus.getExtension(PolicyDataEngine.class);
    pde.assertMessage(message, calcServerPolicy(message), new ServerPolicyCalculator());
}
Also used : PolicyDataEngine(org.apache.cxf.policy.PolicyDataEngine) ServerPolicyCalculator(org.apache.cxf.transport.http.policy.impl.ServerPolicyCalculator)

Example 7 with ServerPolicyCalculator

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

the class HTTPServerAssertionBuilderTest method testBuildAssertion.

@Test
public void testBuildAssertion() throws Exception {
    HTTPServerAssertionBuilder ab = new HTTPServerAssertionBuilder();
    Assertion a = ab.buildAssertion();
    assertTrue(a instanceof JaxbAssertion);
    assertTrue(a instanceof HTTPServerAssertionBuilder.HTTPServerPolicyAssertion);
    assertEquals(new ServerPolicyCalculator().getDataClassName(), a.getName());
    assertTrue(!a.isOptional());
}
Also used : JaxbAssertion(org.apache.cxf.ws.policy.builder.jaxb.JaxbAssertion) Assertion(org.apache.neethi.Assertion) JaxbAssertion(org.apache.cxf.ws.policy.builder.jaxb.JaxbAssertion) ServerPolicyCalculator(org.apache.cxf.transport.http.policy.impl.ServerPolicyCalculator) Test(org.junit.Test)

Example 8 with ServerPolicyCalculator

use of org.apache.cxf.transport.http.policy.impl.ServerPolicyCalculator 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();
}
Also used : Exchange(org.apache.cxf.message.Exchange) PolicyAssertion(org.apache.cxf.ws.policy.PolicyAssertion) HTTPServerPolicy(org.apache.cxf.transports.http.configuration.HTTPServerPolicy) AssertionInfo(org.apache.cxf.ws.policy.AssertionInfo) Message(org.apache.cxf.message.Message) ArrayList(java.util.ArrayList) ServerPolicyCalculator(org.apache.cxf.transport.http.policy.impl.ServerPolicyCalculator) PolicyDataEngineImpl(org.apache.cxf.ws.policy.PolicyDataEngineImpl) AssertionInfoMap(org.apache.cxf.ws.policy.AssertionInfoMap)

Aggregations

ServerPolicyCalculator (org.apache.cxf.transport.http.policy.impl.ServerPolicyCalculator)8 HTTPServerPolicy (org.apache.cxf.transports.http.configuration.HTTPServerPolicy)5 Test (org.junit.Test)4 PolicyDataEngine (org.apache.cxf.policy.PolicyDataEngine)3 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 ClientPolicyCalculator (org.apache.cxf.transport.http.policy.impl.ClientPolicyCalculator)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