コード例 #1
0
ファイル: XmlTest.java プロジェクト: eatlunchnow/opennms
 @Test
 public void validateCastorObjectAgainstSchema() throws Exception {
   org.exolab.castor.xml.Unmarshaller unmarshaller = CastorUtils.getUnmarshaller(getSampleClass());
   unmarshaller.setValidation(true);
   @SuppressWarnings("unchecked")
   T obj = (T) unmarshaller.unmarshal(new InputSource(getSampleXmlInputStream()));
   assertNotNull(obj);
 }
コード例 #2
0
ファイル: PubSubScenario.java プロジェクト: jjpopski/ACS
 /** Loads the test spec (castor classes) from an xml file. */
 public PubSubScenario(Logger logger, File xmlFile, boolean validateXml)
     throws FileNotFoundException, IOException, MarshalException, ValidationException {
   this.logger = logger;
   if (xmlFile.exists() && !xmlFile.isDirectory() && xmlFile.canRead()) {
     Unmarshaller unm = new Unmarshaller(PubSubInfrastructureSpec.class);
     unm.setValidation(validateXml);
     spec = (PubSubInfrastructureSpec) unm.unmarshal(new FileReader(xmlFile));
   } else {
     throw new FileNotFoundException(xmlFile.getAbsolutePath());
   }
 }