sMarkup +
"</anyInterfaceElement> </XMLAnyTest>";
try
{
m_parser.parse(new StringInput(sMessage), m_message);
fail("Expected IntegrationException");
}
catch (IntegrationException ex)
{
assertEquals("err.integration.xml.invalidElement", ex.getErrorCode());
assertEquals("anyInterfaceElement", ex.getErrorArgs()[1]);
assertEquals("XMLAnyTest", ex.getErrorArgs()[2]);
}
// There can be at most 1 of "anyTypeElementComp"
sMessage = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<XMLAnyTest> <anyTypeElementComp attribute=\"123\"> " +
sMarkup +
"</anyTypeElementComp> <anyTypeElementComp attribute=\"456\">" +
sMarkup +
"</anyTypeElementComp> </XMLAnyTest>";
try
{
m_parser.parse(new StringInput(sMessage), m_message);
fail("Expected IntegrationException");
}
catch (IntegrationException ex)
{
assertEquals("err.integration.xml.invalidElement", ex.getErrorCode());
assertEquals("anyTypeElementComp", ex.getErrorArgs()[1]);
assertEquals("XMLAnyTest", ex.getErrorArgs()[2]);
}
// There can be at most 3 of "anyInterfaceElementCompCollection"
String sItem = "<anyInterfaceElementCompCollection> <before>pre</before>" + sMarkup + "</anyInterfaceElementCompCollection>";
sMessage = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<XMLAnyTest> " +
sItem + sItem + sItem + sItem +
"</XMLAnyTest>";
try
{
m_parser.parse(new StringInput(sMessage), m_message);
fail("Expected IntegrationException");
}
catch (IntegrationException ex)
{
assertEquals("err.integration.maxPartCount", ex.getErrorCode());
assertEquals("XMLAnyTest anyInterfaceElementCompCollection", ex.getErrorArgs()[0]);
}
// There can be at most 2 of the value part.
sMessage = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<XMLAnyTest> <anyInterfaceElementCompCollection>" +
sMarkup + sMarkup + sMarkup + sMarkup +
"</anyInterfaceElementCompCollection> </XMLAnyTest>";
try
{
m_parser.parse(new StringInput(sMessage), m_message);
fail("Expected IntegrationException");
}
catch (IntegrationException ex)
{
assertEquals("err.integration.maxPartCount", ex.getErrorCode());
assertEquals("XMLAnyTest anyInterfaceElementCompCollection value", ex.getErrorArgs()[0]);
}
// The <before> element is missing
sMessage = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<XMLAnyTest> <anyInterfaceElementComp>" +
sMarkup +
"</anyInterfaceElementComp> </XMLAnyTest>";
try
{
m_parser.parse(new StringInput(sMessage), m_message);
fail("Expected IntegrationException");
}
catch (IntegrationException ex)
{
assertEquals("err.integration.minPartCount", ex.getErrorCode());