artifactExtensionPoint.addArtifactProcessor(new TuscanyWSPolicyAssertionProcessor());
StAXAttributeProcessorExtensionPoint attributeExtensionPoint = registry.getExtensionPoint(StAXAttributeProcessorExtensionPoint.class);
StAXAttributeProcessor<Object> extensibleStAXAttributeProcessor = new ExtensibleStAXAttributeProcessor(attributeExtensionPoint, inputFactory, outputFactory);
BuilderExtensionPoint builderExtensionPoint = registry.getExtensionPoint(BuilderExtensionPoint.class);
StAXArtifactProcessor processor = artifactExtensionPoint.getProcessor(Definitions.class);
Object artifact = null;
// Read the first definitions string
XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(WS_POLICY1));
artifact = processor.read(reader, new ProcessorContext());
assertNotNull(artifact);
Assert.assertTrue(artifact instanceof Definitions);
Definitions definitions1 = (Definitions) artifact;
// Read the second definitions string
reader = inputFactory.createXMLStreamReader(new StringReader(WS_POLICY2));
artifact = processor.read(reader, new ProcessorContext());
assertNotNull(artifact);
Assert.assertTrue(artifact instanceof Definitions);
Definitions definitions2 = (Definitions) artifact;
// compare the policies using the policy builder
// create dummy endpoints and endpoint references
AssemblyFactory assemblyFactory = modelFactories.getFactory(AssemblyFactory.class);
EndpointReference epr = assemblyFactory.createEndpointReference();
Endpoint ep = assemblyFactory.createEndpoint();
// add the ws polices we've just read to the epr/ep
epr.getPolicySets().add(definitions1.getPolicySets().get(0));
ep.getPolicySets().add(definitions1.getPolicySets().get(0));
BuilderContext builderContext = new BuilderContext((Monitor)null);
for (PolicyBuilder policyBuilder : builderExtensionPoint.getPolicyBuilders()) {
System.out.println("PolicyBuilder: " + policyBuilder.toString());
assertTrue(policyBuilder.build(epr, ep, builderContext));
}
}