use of org.apache.cxf.ws.policy.attachment.wsdl11.Wsdl11AttachmentPolicyProvider 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);
}
}
}
Aggregations