Search in sources :

Example 11 with Project

use of org.evosuite.xsd.Project in project evosuite by EvoSuite.

the class StorageManager method getProject.

private static Project getProject(File current, InputStream stream) {
    try {
        JAXBContext jaxbContext = JAXBContext.newInstance(Project.class);
        SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
        Schema schema = factory.newSchema(new StreamSource(StorageManager.class.getResourceAsStream("/xsd/ctg_project_report.xsd")));
        Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
        jaxbUnmarshaller.setSchema(schema);
        return (Project) jaxbUnmarshaller.unmarshal(stream);
    } catch (Exception e) {
        String msg = "Error in reading " + current.getAbsolutePath() + " , " + e;
        logger.error(msg, e);
        throw new RuntimeException(msg);
    }
}
Also used : SchemaFactory(javax.xml.validation.SchemaFactory) Project(org.evosuite.xsd.Project) Schema(javax.xml.validation.Schema) StreamSource(javax.xml.transform.stream.StreamSource) JAXBContext(javax.xml.bind.JAXBContext) Unmarshaller(javax.xml.bind.Unmarshaller) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException)

Aggregations

Project (org.evosuite.xsd.Project)11 Test (org.junit.Test)8 CUT (org.evosuite.xsd.CUT)5 Generation (org.evosuite.xsd.Generation)5 TestSuite (org.evosuite.xsd.TestSuite)2 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 JAXBContext (javax.xml.bind.JAXBContext)1 Unmarshaller (javax.xml.bind.Unmarshaller)1 StreamSource (javax.xml.transform.stream.StreamSource)1 Schema (javax.xml.validation.Schema)1 SchemaFactory (javax.xml.validation.SchemaFactory)1