"<player><firstName>My1</firstName><guid>AQIDBAUGBwgJEBESExQVFg==</guid>" +
"<id type=\"OHIP\" b:id=\"111222333\"/></player></a:Patient>";
try
{
message = m_parser.parse(new StringInput(sMessage), m_patient);
fail("Expected IntegrationException");
}
catch (IntegrationException ex)
{
assertEquals("err.integration.minPartCount", ex.getErrorCode());
}
// Required part present but empty
sMessage = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<a:Patient xmlns:a=\"urn:com.nexjsystems:ns:test:a\" " +
"xmlns:b=\"urn:com.nexjsystems:ns:test:b\" " +
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:com.nexjsystems:ns:test:a http://www.nexjsystems.com/nexj/integration.xsd urn:com.nexjsystems:ns:test:b http://www.nexjsystems.com/nexj/b.xsd\">" +
"<player><firstName>My1</firstName><lastName/><guid>AQIDBAUGBwgJEBESExQVFg==</guid>" +
"<id type=\"OHIP\" b:id=\"111222333\"/></player></a:Patient>";
try
{
message = m_parser.parse(new StringInput(sMessage), m_patient);
fail("Expected IntegrationException");
}
catch (IntegrationException ex)
{
assertEquals("err.integration.minPartCount", ex.getErrorCode());
}
// Required part present
sMessage = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<a:Patient xmlns:a=\"urn:com.nexjsystems:ns:test:a\" " +
"xmlns:b=\"urn:com.nexjsystems:ns:test:b\" " +
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:com.nexjsystems:ns:test:a http://www.nexjsystems.com/nexj/integration.xsd urn:com.nexjsystems:ns:test:b http://www.nexjsystems.com/nexj/b.xsd\">" +
"<player><firstName>My1</firstName><lastName>Test</lastName><guid>AQIDBAUGBwgJEBESExQVFg==</guid>" +
"<id type=\"OHIP\" b:id=\"111222333\"/></player></a:Patient>";
message = m_parser.parse(new StringInput(sMessage), m_patient);
player = (TransferObject)message.getValue("player");
assertEquals("Test", player.getValue("lastName"));
assertFalse(player.hasValue("title"));
// Required part present with nil (part is NOT nillable)
sMessage = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<a:Patient xmlns:a=\"urn:com.nexjsystems:ns:test:a\" " +
"xmlns:b=\"urn:com.nexjsystems:ns:test:b\" " +
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:com.nexjsystems:ns:test:a http://www.nexjsystems.com/nexj/integration.xsd urn:com.nexjsystems:ns:test:b http://www.nexjsystems.com/nexj/b.xsd\">" +
"<player><firstName>My1</firstName><lastName xsi:nil=\"true\">Test</lastName><guid>AQIDBAUGBwgJEBESExQVFg==</guid>" +
"<id type=\"OHIP\" b:id=\"111222333\"/></player></a:Patient>";
try
{
message = m_parser.parse(new StringInput(sMessage), m_patient);
fail("Expected IntegrationException");
}
catch (IntegrationException ex)
{
assertEquals("err.integration.xml.messageSyntax", ex.getErrorCode());
}
// Required part empty with nil (part is NOT nillable)
sMessage = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<a:Patient xmlns:a=\"urn:com.nexjsystems:ns:test:a\" " +
"xmlns:b=\"urn:com.nexjsystems:ns:test:b\" " +
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:com.nexjsystems:ns:test:a http://www.nexjsystems.com/nexj/integration.xsd urn:com.nexjsystems:ns:test:b http://www.nexjsystems.com/nexj/b.xsd\">" +
"<player><firstName>My1</firstName><lastName xsi:nil=\"true\"/><guid>AQIDBAUGBwgJEBESExQVFg==</guid>" +
"<id type=\"OHIP\" b:id=\"111222333\"/></player></a:Patient>";
try
{
message = m_parser.parse(new StringInput(sMessage), m_patient);
fail("Expected IntegrationException");
}
catch (IntegrationException ex)
{
assertEquals("err.integration.xml.messageSyntax", ex.getErrorCode());
}
/*
* Tests of parsing a nillable element.
*/
// NILLABLE: Optional part empty with nil
sMessage = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<a:Patient xmlns:a=\"urn:com.nexjsystems:ns:test:a\" " +
"xmlns:b=\"urn:com.nexjsystems:ns:test:b\" " +
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:com.nexjsystems:ns:test:a http://www.nexjsystems.com/nexj/integration.xsd urn:com.nexjsystems:ns:test:b http://www.nexjsystems.com/nexj/b.xsd\">" +
"<player><firstName>My1</firstName><title xsi:nil=\"true\"/><guid>AQIDBAUGBwgJEBESExQVFg==</guid>" +
"<id type=\"OHIP\" b:id=\"111222333\"/></player></a:Patient>";
message = m_parser.parse(new StringInput(sMessage), m_patientNillable);
player = (TransferObject)message.getValue("player");
assertNull(player.getValue("title"));
// NILLABLE: Optional part has text contents with nil
sMessage = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<a:Patient xmlns:a=\"urn:com.nexjsystems:ns:test:a\" " +
"xmlns:b=\"urn:com.nexjsystems:ns:test:b\" " +
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:com.nexjsystems:ns:test:a http://www.nexjsystems.com/nexj/integration.xsd urn:com.nexjsystems:ns:test:b http://www.nexjsystems.com/nexj/b.xsd\">" +
"<player><firstName>My1</firstName><title xsi:nil=\"true\">Test</title><guid>AQIDBAUGBwgJEBESExQVFg==</guid>" +
"<id type=\"OHIP\" b:id=\"111222333\"/></player></a:Patient>";
try
{
message = m_parser.parse(new StringInput(sMessage), m_patientNillable);
fail("Expected IntegrationException");
}
catch (IntegrationException ex)
{
assertEquals("err.integration.xml.nilElementNotEmpty", ex.getErrorCode());
}
// NILLABLE: Optional part has element contents with nil
sMessage = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<a:Patient xmlns:a=\"urn:com.nexjsystems:ns:test:a\" " +
"xmlns:b=\"urn:com.nexjsystems:ns:test:b\" " +
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:com.nexjsystems:ns:test:a http://www.nexjsystems.com/nexj/integration.xsd urn:com.nexjsystems:ns:test:b http://www.nexjsystems.com/nexj/b.xsd\">" +
"<player><firstName>My1</firstName><title xsi:nil=\"true\"><efg/></title><guid>AQIDBAUGBwgJEBESExQVFg==</guid>" +
"<id type=\"OHIP\" b:id=\"111222333\"/></player></a:Patient>";
try
{
message = m_parser.parse(new StringInput(sMessage), m_patientNillable);
fail("Expected IntegrationException");
}
catch (IntegrationException ex)
{
assertEquals("err.integration.xml.nilElementNotEmpty", ex.getErrorCode());
}
// NILLABLE: Attributes allowed when nil
sMessage = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<a:Patient xmlns:a=\"urn:com.nexjsystems:ns:test:a\" " +
"xmlns:b=\"urn:com.nexjsystems:ns:test:b\" " +
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:com.nexjsystems:ns:test:a http://www.nexjsystems.com/nexj/integration.xsd urn:com.nexjsystems:ns:test:b http://www.nexjsystems.com/nexj/b.xsd\">" +
"<player><firstName>My1</firstName><title xsi:nil=\"true\"/><guid>AQIDBAUGBwgJEBESExQVFg==</guid>" +
"<id type=\"OHIP\" b:id=\"111222333\"/>" +
"<telcom useCode=\"T1\" xsi:nil=\"true\"/><telcom2 useCode=\"T2\" xsi:nil=\"true\"/>" +
"</player></a:Patient>";
message = m_parser.parse(new StringInput(sMessage), m_patientNillable);
player = (TransferObject)message.getValue("player");
assertNull(player.getValue("title"));
telcom = (TransferObject)player.getValue("telcom");
assertNull(telcom.getValue("address"));
assertEquals("T1", telcom.getValue("useCode"));
assertEquals(Boolean.TRUE, telcom.getValue("isNil"));
telcom = (TransferObject)player.getValue("telcom2");
assertNull(telcom.getValue("address"));
assertEquals("T2", telcom.getValue("useCode"));
// NILLABLE: Composite part has attribute and is empty (not nil)
sMessage = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<a:Patient xmlns:a=\"urn:com.nexjsystems:ns:test:a\" " +
"xmlns:b=\"urn:com.nexjsystems:ns:test:b\" " +
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:com.nexjsystems:ns:test:a http://www.nexjsystems.com/nexj/integration.xsd urn:com.nexjsystems:ns:test:b http://www.nexjsystems.com/nexj/b.xsd\">" +
"<player><firstName>My1</firstName><title>Test</title><guid>AQIDBAUGBwgJEBESExQVFg==</guid>" +
"<id type=\"OHIP\" b:id=\"111222333\"/>" +
"<telcom useCode=\"T1\"/><telcom2 useCode=\"T2\"/>" +
"</player></a:Patient>";
message = m_parser.parse(new StringInput(sMessage), m_patientNillable);
player = (TransferObject)message.getValue("player");
assertEquals("Test", player.getValue("title"));
telcom = (TransferObject)player.getValue("telcom");
assertNull(telcom.getValue("address"));
assertEquals("T1", telcom.getValue("useCode"));
assertFalse(telcom.hasValue("isNil"));
telcom = (TransferObject)player.getValue("telcom2");
assertNull(telcom.getValue("address"));
assertEquals("T2", telcom.getValue("useCode"));
// NILLABLE: Composite message part nil, but has text content
sMessage = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<a:Patient xmlns:a=\"urn:com.nexjsystems:ns:test:a\" " +
"xmlns:b=\"urn:com.nexjsystems:ns:test:b\" " +
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:com.nexjsystems:ns:test:a http://www.nexjsystems.com/nexj/integration.xsd urn:com.nexjsystems:ns:test:b http://www.nexjsystems.com/nexj/b.xsd\">" +
"<player><firstName>My1</firstName><title xsi:nil=\"true\"/><guid>AQIDBAUGBwgJEBESExQVFg==</guid>" +
"<id type=\"OHIP\" b:id=\"111222333\"/>" +
"<telcom2 useCode=\"T2\" xsi:nil=\"true\">addr2</telcom2>" +
"</player></a:Patient>";
try
{
message = m_parser.parse(new StringInput(sMessage), m_patientNillable);
fail("IntegrationException Expected");
}
catch (IntegrationException ex)
{
assertEquals("err.integration.xml.nilElementNotEmpty", ex.getErrorCode());
}
// NILLABLE: Composite message part nil, but has element content
sMessage = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<a:Patient xmlns:a=\"urn:com.nexjsystems:ns:test:a\" " +
"xmlns:b=\"urn:com.nexjsystems:ns:test:b\" " +
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:com.nexjsystems:ns:test:a http://www.nexjsystems.com/nexj/integration.xsd urn:com.nexjsystems:ns:test:b http://www.nexjsystems.com/nexj/b.xsd\">" +
"<player><firstName>My1</firstName><title xsi:nil=\"true\"/><guid>AQIDBAUGBwgJEBESExQVFg==</guid>" +
"<id type=\"OHIP\" b:id=\"111222333\"/>" +
"<telcom2 useCode=\"T2\" xsi:nil=\"true\"><sub/></telcom2>" +
"</player></a:Patient>";
try
{
message = m_parser.parse(new StringInput(sMessage), m_patientNillable);
fail("IntegrationException Expected");
}
catch (IntegrationException ex)
{
assertEquals("err.integration.xml.nilElementNotEmpty", ex.getErrorCode());