}
public void testPolicyAttachmentReadWrite() throws Exception
{
//Read wsdl containing policies from file and get the wsdl metadata model
WSDLDefinitionsFactory factory = WSDLDefinitionsFactory.newInstance();
WSDLDefinitions wsdlDefinitions = factory.parse(new File("resources/common/wsdl11/PolicyAttachment.wsdl").toURL());
assertNotNull(wsdlDefinitions);
//set wsdlOneOne to null to force wsdl generation from metadata model
wsdlDefinitions.setWsdlOneOneDefinition(null);
//process the wsdl metadata model writing it back to another file
File wsdlDir = new File("./tools/wsdl-out");
if (!wsdlDir.exists()) wsdlDir.mkdirs();
Writer fw = IOUtils.getCharsetFileWriter(new File(wsdlDir+"/GeneratedWsdlWithPolicies.wsdl"), Constants.DEFAULT_XML_CHARSET);
new WSDLWriter(wsdlDefinitions).write(fw, Constants.DEFAULT_XML_CHARSET);
fw.close();
//parse the obtained file and validate the resulting wsdl metadata model against the first one
WSDLDefinitions newWsdlDefinitions = factory.parse(new File(wsdlDir+"/GeneratedWsdlWithPolicies.wsdl").toURL());
assertNotNull(newWsdlDefinitions);
WSDLValidator validator = new WSDLValidator();
assertTrue(validator.validate(wsdlDefinitions,newWsdlDefinitions));
}