JaxbUtil { public static Schema createSchemaIfNull(String xsd, Schema schema) { if (schema != null) return schema; try { SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); StreamSource xsdSource = new StreamSource(SourceStringsParser.class.getClassLoader().getResourceAsStream(xsd)); return sf.newSchema(xsdSource); } catch (SAXException e) { LOG.error("Failed to create schema at '{}' ", xsd, e); return null; } } private  JaxbUtil(); static JAXBContext createContextIfNull(Class<T> clazz, JAXBContext context); @SuppressWarnings("unchecked") static T convertTo(byte[] xml, JAXBContext context, Schema validationSchema, ValidationEventHandler validationEventHandler); static String convertToString(T xmlObject, JAXBContext context, Schema validationSchema, ValidationEventHandler validationEventHandler); static Schema createSchemaIfNull(String xsd, Schema schema); static String getErrorLocation(ValidationEvent event); static String getXmlMixedContentAsString(List<Object> contents); static String convertNodeToString(Node node); static Node convertStringToNode(String xmlStr);  }
@Test public void createSchema() throws IOException, URISyntaxException { Schema schema = null; schema = JaxbUtil.createSchemaIfNull(XSD_SCHEMA, schema); assertNotNull(schema); }