### Question:
XsdContentValidator extends XmlContentValidator { @Override public void validate(ValidityLevel level, ContentHandle artifactContent) throws InvalidContentException { super.validate(level, artifactContent); if (level == ValidityLevel.FULL) { try (InputStream semanticStream = artifactContent.stream()) { Source source = new StreamSource(semanticStream); SchemaFactoryAccessor.getSchemaFactory().newSchema(source); } catch (Exception e) { throw new InvalidContentException("Syntax violation for XSD Schema artifact.", e); } } } XsdContentValidator(); @Override void validate(ValidityLevel level, ContentHandle artifactContent);  }### Answer:
@Test public void testValidSyntax() throws Exception { ContentHandle contentA = resourceToContentHandle("xml-schema-valid.xsd"); XsdContentValidator validator = new XsdContentValidator(); validator.validate(ValidityLevel.SYNTAX_ONLY, contentA); ContentHandle contentB = resourceToContentHandle("xml-schema-invalid-semantics.xsd"); validator.validate(ValidityLevel.SYNTAX_ONLY, contentB); }
@Test public void testInvalidSyntax() throws Exception { ContentHandle content = resourceToContentHandle("xml-schema-invalid-syntax.xsd"); XsdContentValidator validator = new XsdContentValidator(); Assertions.assertThrows(InvalidContentException.class, () -> { validator.validate(ValidityLevel.SYNTAX_ONLY, content); }); }
@Test public void testValidSemantics() throws Exception { ContentHandle content = resourceToContentHandle("xml-schema-valid.xsd"); XsdContentValidator validator = new XsdContentValidator(); validator.validate(ValidityLevel.FULL, content); }
@Test public void testInvalidSemantics() throws Exception { ContentHandle content = resourceToContentHandle("xml-schema-invalid-semantics.xsd"); XsdContentValidator validator = new XsdContentValidator(); Assertions.assertThrows(InvalidContentException.class, () -> { validator.validate(ValidityLevel.FULL, content); }); }