Index: Ringtoets/Common/src/Ringtoets.Common.IO/Readers/ConfigurationReader.cs
===================================================================
diff -u -r8a00046f9112833f25944b0f2631c7003f7a1692 -r94587578a17566618ad7b26fc914d8b4d30fb99b
--- Ringtoets/Common/src/Ringtoets.Common.IO/Readers/ConfigurationReader.cs (.../ConfigurationReader.cs) (revision 8a00046f9112833f25944b0f2631c7003f7a1692)
+++ Ringtoets/Common/src/Ringtoets.Common.IO/Readers/ConfigurationReader.cs (.../ConfigurationReader.cs) (revision 94587578a17566618ad7b26fc914d8b4d30fb99b)
@@ -148,9 +148,10 @@
/// Thrown when the provided XML document does not match the provided XML Schema Definition (XSD).
private static void ValidateToSchema(XDocument document, string schemaString, string xmlFilePath)
{
+ var xmlResourcesResolver = new XmlResourcesResolver();
var xmlSchemaSet = new XmlSchemaSet
{
- XmlResolver = new XmlResourcesResolver()
+ XmlResolver = xmlResourcesResolver
};
try
@@ -163,6 +164,11 @@
throw new ArgumentException($"Invalid 'schemaString': {exception.Message}", exception);
}
+ if (!xmlResourcesResolver.BaseSchemeReferenced)
+ {
+ throw new ArgumentException("Invalid 'schemaString': the base XML Schema Definition file 'ConfiguratieSchema.xsd' is not referenced.");
+ }
+
try
{
document.Validate(xmlSchemaSet, null);
@@ -229,11 +235,14 @@
}
}
+ public bool BaseSchemeReferenced { get; private set; }
+
public override object GetEntity(Uri absoluteUri, string role, Type ofObjectToReturn)
{
switch (Path.GetFileName(absoluteUri.ToString()))
{
case "ConfiguratieSchema.xsd":
+ BaseSchemeReferenced = true;
return new MemoryStream(Encoding.UTF8.GetBytes(Resources.ConfiguratieSchema));
case "StochastSchema.xsd":
return new MemoryStream(Encoding.UTF8.GetBytes(Resources.StochastSchema));
Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/Readers/ConfigurationReaderTest.cs
===================================================================
diff -u -r789a1cf222034a729160372a650c4b5249d1e796 -r94587578a17566618ad7b26fc914d8b4d30fb99b
--- Ringtoets/Common/test/Ringtoets.Common.IO.Test/Readers/ConfigurationReaderTest.cs (.../ConfigurationReaderTest.cs) (revision 789a1cf222034a729160372a650c4b5249d1e796)
+++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/Readers/ConfigurationReaderTest.cs (.../ConfigurationReaderTest.cs) (revision 94587578a17566618ad7b26fc914d8b4d30fb99b)
@@ -124,7 +124,9 @@
[TestCase("invalidXsdContent.xsd",
"Invalid 'schemaString': The root element of a W3C XML Schema should be and its namespace should be 'http://www.w3.org/2001/XMLSchema'.",
typeof(XmlSchemaException))]
- public void Constructor_InvalidSchemaString_ThrowArgumentException(string fileName, string expectedMessage, Type expectedExceptionType)
+ [TestCase("notReferencingBaseXsd.xsd",
+ "Invalid 'schemaString': the base XML Schema Definition file 'ConfiguratieSchema.xsd' is not referenced.")]
+ public void Constructor_InvalidSchemaString_ThrowArgumentException(string fileName, string expectedMessage, Type expectedInnerExceptionType = null)
{
// Setup
string filePath = Path.Combine(testDirectoryPath, "validConfiguration.xml");
@@ -136,7 +138,11 @@
// Assert
var exception = Assert.Throws(call);
Assert.AreEqual(expectedMessage, exception.Message);
- Assert.IsInstanceOf(expectedExceptionType, exception.InnerException);
+
+ if (expectedInnerExceptionType != null)
+ {
+ Assert.IsInstanceOf(expectedInnerExceptionType, exception.InnerException);
+ }
}
[Test]
@@ -198,7 +204,7 @@
public ConfigurationReaderTest()
{
- schemaString = File.ReadAllText(Path.Combine(testDirectoryPath, "ConfiguratieSchema.xsd"));
+ schemaString = File.ReadAllText(Path.Combine(testDirectoryPath, "validConfigurationSchema.xsd"));
}
private class TestConfigurationReader : ConfigurationReader
Fisheye: Tag 94587578a17566618ad7b26fc914d8b4d30fb99b refers to a dead (removed) revision in file `Ringtoets/Common/test/Ringtoets.Common.IO.Test/test-data/ConfigurationReader/ConfiguratieSchema.xsd'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/test-data/ConfigurationReader/notReferencingBaseXsd.xsd
===================================================================
diff -u
--- Ringtoets/Common/test/Ringtoets.Common.IO.Test/test-data/ConfigurationReader/notReferencingBaseXsd.xsd (revision 0)
+++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/test-data/ConfigurationReader/notReferencingBaseXsd.xsd (revision 94587578a17566618ad7b26fc914d8b4d30fb99b)
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/test-data/ConfigurationReader/validConfigurationSchema.xsd
===================================================================
diff -u
--- Ringtoets/Common/test/Ringtoets.Common.IO.Test/test-data/ConfigurationReader/validConfigurationSchema.xsd (revision 0)
+++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/test-data/ConfigurationReader/validConfigurationSchema.xsd (revision 94587578a17566618ad7b26fc914d8b4d30fb99b)
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file