additional SPRNET-912 fix
This commit is contained in:
@@ -122,17 +122,45 @@ namespace Spring.Objects.Factory.Xml
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException(typeof(XmlObjectDefinitionStoreException))]
|
||||
public void ThrowsObjectDefinitionStoreExceptionOnValidationError()
|
||||
{
|
||||
DefaultListableObjectFactory of = new DefaultListableObjectFactory();
|
||||
XmlObjectDefinitionReader reader = new XmlObjectDefinitionReader(of);
|
||||
reader.LoadObjectDefinitions(new StringResource(
|
||||
@"<?xml version='1.0' encoding='UTF-8' ?>
|
||||
<objects xmlns='http://www.springframework.net'>
|
||||
<INVALIDELEMENT id='test2' type='Spring.Objects.TestObject, Spring.Core.Tests' />
|
||||
</objects>
|
||||
"));
|
||||
try
|
||||
{
|
||||
DefaultListableObjectFactory of = new DefaultListableObjectFactory();
|
||||
XmlObjectDefinitionReader reader = new XmlObjectDefinitionReader(of);
|
||||
reader.LoadObjectDefinitions(new StringResource(
|
||||
@"<?xml version='1.0' encoding='UTF-8' ?>
|
||||
<objects xmlns='http://www.springframework.net'>
|
||||
<INVALIDELEMENT id='test2' type='Spring.Objects.TestObject, Spring.Core.Tests' />
|
||||
</objects>
|
||||
"));
|
||||
Assert.Fail();
|
||||
}
|
||||
catch(ObjectDefinitionStoreException ex)
|
||||
{
|
||||
Assert.IsTrue( ex.Message.IndexOf("Line 3 in XML document from violates the schema.") > -1);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ThrowsObjectDefinitionStoreExceptionOnInvalidXml()
|
||||
{
|
||||
try
|
||||
{
|
||||
DefaultListableObjectFactory of = new DefaultListableObjectFactory();
|
||||
XmlObjectDefinitionReader reader = new XmlObjectDefinitionReader(of);
|
||||
reader.LoadObjectDefinitions(new StringResource(
|
||||
@"<?xml version='1.0' encoding='UTF-8' ?>
|
||||
<objects xmlns='http://www.springframework.net'>
|
||||
<object id='test2' type='Spring.Objects.TestObject, Spring.Core.Tests'>
|
||||
</objects>
|
||||
"));
|
||||
Assert.Fail();
|
||||
}
|
||||
catch(ObjectDefinitionStoreException ex)
|
||||
{
|
||||
Assert.IsTrue( ex.Message.IndexOf("Line 4 in XML document from is not well formed.") > -1);
|
||||
}
|
||||
}
|
||||
|
||||
#region ThrowsObjectDefinitionStoreExceptionOnErrorDuringObjectDefinitionRegistration Helper
|
||||
|
||||
@@ -993,15 +993,10 @@ namespace Spring.Objects.Factory.Xml
|
||||
reader.LoadObjectDefinitions(new ReadOnlyXmlTestResource("invalid.xml", GetType()));
|
||||
Assert.Fail("Should have thrown XmlObjectDefinitionStoreException");
|
||||
}
|
||||
#if !NET_1_0
|
||||
catch (XmlObjectDefinitionStoreException e)
|
||||
catch (ObjectDefinitionStoreException e)
|
||||
{
|
||||
Assert.AreEqual(0, e.Message.IndexOf("Line 21 in XML document"));
|
||||
}
|
||||
#else
|
||||
catch (XmlObjectDefinitionStoreException)
|
||||
{}
|
||||
#endif
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -1014,16 +1009,10 @@ namespace Spring.Objects.Factory.Xml
|
||||
reader.LoadObjectDefinitions(new ReadOnlyXmlTestResource("invalid.xml", GetType()));
|
||||
Assert.Fail("Should have thrown XmlObjectDefinitionStoreException");
|
||||
}
|
||||
#if !NET_1_0
|
||||
catch (XmlObjectDefinitionStoreException e)
|
||||
catch (ObjectDefinitionStoreException e)
|
||||
{
|
||||
Assert.AreEqual(0, e.Message.IndexOf("Line 21 in XML document"));
|
||||
}
|
||||
#else
|
||||
catch (XmlObjectDefinitionStoreException)
|
||||
{}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
Reference in New Issue
Block a user