Package org.apache.cxf.transport.http.policy.impl

Examples of org.apache.cxf.transport.http.policy.impl.ClientPolicyCalculator


        assertTrue(!calc.equals(p1, p2));
    }
   
    @Test
    public void testLongTimeouts() {
        ClientPolicyCalculator calc = new ClientPolicyCalculator();
        HTTPClientPolicy p1 = new HTTPClientPolicy();
        HTTPClientPolicy p2 = new HTTPClientPolicy();
        p2.setReceiveTimeout(120000);
        p2.setConnectionTimeout(60000);
        HTTPClientPolicy p = calc.intersect(p1, p2);
        assertEquals(120000, p.getReceiveTimeout());
        assertEquals(60000, p.getConnectionTimeout());
       
        p1 = new HTTPClientPolicy();
        p2 = new HTTPClientPolicy();
        p1.setReceiveTimeout(120000);
        p1.setConnectionTimeout(60000);
        p = calc.intersect(p1, p2);
        assertEquals(120000, p.getReceiveTimeout());
        assertEquals(60000, p.getConnectionTimeout());

        p2.setReceiveTimeout(50000);
        p2.setConnectionTimeout(20000);
        p = calc.intersect(p1, p2);
        //p1 should have priority
        assertEquals(120000, p.getReceiveTimeout());
        assertEquals(60000, p.getConnectionTimeout());

        //reverse intersect
        p = calc.intersect(p2, p1);
        //p2 should have priority
        assertEquals(50000, p.getReceiveTimeout());
        assertEquals(20000, p.getConnectionTimeout());
    }
View Full Code Here


        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<PolicyAssertion>();
        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();
    }
View Full Code Here

        testAssertClientPolicy(false);
    }
   
    public AssertionInfo getClientPolicyAssertionInfo(HTTPClientPolicy policy) {
        JaxbAssertion<HTTPClientPolicy> assertion =
            new JaxbAssertion<HTTPClientPolicy>(new ClientPolicyCalculator().getDataClassName(), false);
        assertion.setData(policy);
        return new AssertionInfo(assertion);
    }
View Full Code Here

                                                                   PolicyAssertion.class));
        Collection<AssertionInfo> ais = new ArrayList<AssertionInfo>();
        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(outbound ? !icmai.isAsserted() : icmai.isAsserted());
        control.verify();
    }
View Full Code Here

    public void testBuildAssertion() throws Exception {
        HTTPClientAssertionBuilder ab = new HTTPClientAssertionBuilder();
        Assertion a = ab.buildAssertion();
        assertTrue(a instanceof JaxbAssertion);
        assertTrue(a instanceof HTTPClientAssertionBuilder.HTTPClientPolicyAssertion);
        assertEquals(new ClientPolicyCalculator().getDataClassName(), a.getName());
        assertTrue(!a.isOptional());
    }
View Full Code Here

import org.junit.Test;

public class ClientPolicyCalculatorTest extends Assert {
    @Test
    public void testCompatibleClientPolicies() {
        ClientPolicyCalculator calc = new ClientPolicyCalculator();
        HTTPClientPolicy p1 = new HTTPClientPolicy();
        assertTrue("Policy is not compatible with itself.", calc.compatible(p1, p1));
        HTTPClientPolicy p2 = new HTTPClientPolicy();
        assertTrue("Policies are not compatible.", calc.compatible(p1, p2));
        p1.setBrowserType("browser");
        assertTrue("Policies are not compatible.", calc.compatible(p1, p2));
        p1.setBrowserType(null);
        p1.setConnectionTimeout(10000);
        assertTrue("Policies are not compatible.", calc.compatible(p1, p2));
        p1.setAllowChunking(false);
        assertTrue("Policies are compatible.", !calc.compatible(p1, p2));
        p2.setAllowChunking(false);
        assertTrue("Policies are compatible.", calc.compatible(p1, p2));
    }
View Full Code Here

        assertTrue("Policies are compatible.", calc.compatible(p1, p2));
    }

    @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());
    }
View Full Code Here

        assertTrue(!p.isAllowChunking());
    }
   
    @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));
    }
View Full Code Here

     */
    private void updateClientPolicy() {
        PolicyDataEngine policyEngine = bus.getExtension(PolicyDataEngine.class);
        if (policyEngine != null && endpointInfo.getService() != null) {
            clientSidePolicy = policyEngine.getClientEndpointPolicy(endpointInfo,
                                                                    this, new ClientPolicyCalculator());
        }
    }
View Full Code Here

    public void setAuthorization(AuthorizationPolicy authorization) {
        this.authorizationPolicy = authorization;
    }
   
    public HTTPClientPolicy getClient(Message message) {
        ClientPolicyCalculator cpc = new ClientPolicyCalculator();
        HTTPClientPolicy messagePol = message.get(HTTPClientPolicy.class);
        if (messagePol != null) {
            return cpc.intersect(messagePol, clientSidePolicy);
        }

        PolicyDataEngine policyDataEngine = bus.getExtension(PolicyDataEngine.class);
        if (policyDataEngine == null) {
            return clientSidePolicy;
View Full Code Here

TOP

Related Classes of org.apache.cxf.transport.http.policy.impl.ClientPolicyCalculator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.