Search in sources :

Example 1 with ServiceModelPolicyProvider

use of org.apache.cxf.ws.policy.attachment.ServiceModelPolicyProvider in project cxf by apache.

the class PolicyExtensionsTest method testExtensions.

@Test
public void testExtensions() {
    Bus bus = null;
    try {
        bus = new SpringBusFactory().createBus("/org/apache/cxf/ws/policy/policy-bus.xml", false);
        AssertionBuilderRegistry abr = bus.getExtension(AssertionBuilderRegistry.class);
        assertNotNull(abr);
        AssertionBuilder<?> ab = abr.getBuilder(KNOWN);
        assertNotNull(ab);
        ab = abr.getBuilder(UNKNOWN);
        assertNull(ab);
        PolicyInterceptorProviderRegistry pipr = bus.getExtension(PolicyInterceptorProviderRegistry.class);
        assertNotNull(pipr);
        Set<PolicyInterceptorProvider> pips = pipr.get(KNOWN);
        assertNotNull(pips);
        assertFalse(pips.isEmpty());
        pips = pipr.get(UNKNOWN);
        assertNotNull(pips);
        assertTrue(pips.isEmpty());
        DomainExpressionBuilderRegistry debr = bus.getExtension(DomainExpressionBuilderRegistry.class);
        assertNotNull(debr);
        DomainExpressionBuilder deb = debr.get(KNOWN_DOMAIN_EXPR_TYPE);
        assertNotNull(deb);
        deb = debr.get(UNKNOWN);
        assertNull(deb);
        PolicyEngine pe = bus.getExtension(PolicyEngine.class);
        assertNotNull(pe);
        PolicyEngineImpl engine = (PolicyEngineImpl) pe;
        assertNotNull(engine.getPolicyProviders());
        assertNotNull(engine.getRegistry());
        Collection<PolicyProvider> pps = engine.getPolicyProviders();
        assertEquals(3, pps.size());
        boolean wsdlProvider = false;
        boolean externalProvider = false;
        boolean serviceProvider = false;
        for (PolicyProvider pp : pps) {
            if (pp instanceof Wsdl11AttachmentPolicyProvider) {
                wsdlProvider = true;
            } else if (pp instanceof ExternalAttachmentProvider) {
                externalProvider = true;
            } else if (pp instanceof ServiceModelPolicyProvider) {
                serviceProvider = true;
            }
        }
        assertTrue(wsdlProvider);
        assertTrue(externalProvider);
        assertTrue(serviceProvider);
        PolicyBuilder builder = bus.getExtension(PolicyBuilder.class);
        assertNotNull(builder);
    } finally {
        if (null != bus) {
            bus.shutdown(true);
            BusFactory.setDefaultBus(null);
        }
    }
}
Also used : Bus(org.apache.cxf.Bus) DomainExpressionBuilder(org.apache.cxf.ws.policy.attachment.external.DomainExpressionBuilder) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) DomainExpressionBuilderRegistry(org.apache.cxf.ws.policy.attachment.external.DomainExpressionBuilderRegistry) ServiceModelPolicyProvider(org.apache.cxf.ws.policy.attachment.ServiceModelPolicyProvider) Wsdl11AttachmentPolicyProvider(org.apache.cxf.ws.policy.attachment.wsdl11.Wsdl11AttachmentPolicyProvider) ServiceModelPolicyProvider(org.apache.cxf.ws.policy.attachment.ServiceModelPolicyProvider) ExternalAttachmentProvider(org.apache.cxf.ws.policy.attachment.external.ExternalAttachmentProvider) Wsdl11AttachmentPolicyProvider(org.apache.cxf.ws.policy.attachment.wsdl11.Wsdl11AttachmentPolicyProvider) Test(org.junit.Test)

Aggregations

Bus (org.apache.cxf.Bus)1 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)1 ServiceModelPolicyProvider (org.apache.cxf.ws.policy.attachment.ServiceModelPolicyProvider)1 DomainExpressionBuilder (org.apache.cxf.ws.policy.attachment.external.DomainExpressionBuilder)1 DomainExpressionBuilderRegistry (org.apache.cxf.ws.policy.attachment.external.DomainExpressionBuilderRegistry)1 ExternalAttachmentProvider (org.apache.cxf.ws.policy.attachment.external.ExternalAttachmentProvider)1 Wsdl11AttachmentPolicyProvider (org.apache.cxf.ws.policy.attachment.wsdl11.Wsdl11AttachmentPolicyProvider)1 Test (org.junit.Test)1