StubConfigSchemaParser { public Schema parseSchema() { Schema result; try { URL schemaFile = resourceLoader.loadResource(stubConfigSchemaLocation); SchemaFactory schemaFactory = schemaFactoryBuilder.buildSchemaFactory(); result = schemaFactory.newSchema(schemaFile); } catch (SAXException e) { throw new DescriptorValidationFailedException("Parsing of stub config XSD failed.", e); } return result; }  Schema parseSchema();  }
@Test public void testParseSchemaShouldNotReturnNullWhenSchemaCanBeParsed() throws SAXException { given(schemaFactoryBuilder.buildSchemaFactory()).willReturn(schemaFactory); given(schemaFactory.newSchema(url)).willReturn(schema); Schema result = underTest.parseSchema(); assertNotNull(result); }
@Test(expectedExceptions = DescriptorValidationFailedException.class) public void testParseSchemaShouldThrowDescriptorValidationFailedExceptionWhenSchemaCanNotBeParsed() throws SAXException { given(schemaFactoryBuilder.buildSchemaFactory()).willReturn(schemaFactory); given(schemaFactory.newSchema(url)).willThrow(new SAXException()); underTest.parseSchema(); }