assertNull(root.getValue("middleName"));
}
public void testParseRootInheritanceWithMessageTable()
{
MessageTable table = new MessageTable();
ObjectInput in;
TransferObject root;
table.addMessage(m_patientMsg);
table.addMessage(m_surgeonMsg);
m_parser.initializeMessageTable(table);
// Parse Patient (uses Object_Inherit_Patient)
in = new ObjectInput(m_patient);
root = m_parser.parse(in, table);
assertEquals("Object_Inherit_Patient", root.getClassName());
assertEquals("Sarah", root.getValue("firstName"));
assertEquals("Johnson", root.getValue("lastName"));
assertTrue(root.hasValue("middleName"));
assertNull(root.getValue("middleName"));
// Parse Surgeon (uses Object_Inherit_Surgeon)
in = new ObjectInput(m_surgeon);
root = m_parser.parse(in, table);
assertEquals("Object_Inherit_Surgeon", root.getClassName());
assertEquals("Joshua", root.getValue("firstName"));
assertEquals("Zig", root.getValue("lastName"));
assertEquals("ECG", root.getValue("speciality"));
assertFalse(root.hasValue("middleName"));
// Parse Contact--error
try
{
in = new ObjectInput(m_contact);
m_parser.parse(in, table);
fail("Expected IntegrationException");
}
catch (IntegrationException ex)
{
assertEquals("err.integration.object.unsupportedMessage", ex.getErrorCode());
}
// Parse Doctor--error
try
{
in = new ObjectInput(m_doctor);
m_parser.parse(in, table);
fail("Expected IntegrationException");
}
catch (IntegrationException ex)
{
assertEquals("err.integration.object.unsupportedMessage", ex.getErrorCode());
}
// Change table
table.addMessage(m_contactMsg);
m_parser.initializeMessageTable(table);
// Parse Contact (uses Object_Inherit_Contact)
in = new ObjectInput(m_contact);
root = m_parser.parse(in, table);
assertEquals("Object_Inherit_Contact", root.getClassName());
assertEquals("Joe", root.getValue("firstName"));
assertFalse(root.hasValue("lastName"));
// Parse Patient (uses Object_Inherit_Patient, polymorphic from Object_Inherit_Contact)
in = new ObjectInput(m_patient);
root = m_parser.parse(in, table);
assertEquals("Object_Inherit_Patient", root.getClassName());
assertEquals("Sarah", root.getValue("firstName"));
assertEquals("Johnson", root.getValue("lastName"));
assertTrue(root.hasValue("middleName"));
assertNull(root.getValue("middleName"));
// Parse Doctor (uses Object_Inherit_Contact)
in = new ObjectInput(m_doctor);
root = m_parser.parse(in, table);
assertEquals("Object_Inherit_Contact", root.getClassName());
assertEquals("Johan", root.getValue("firstName"));
assertFalse(root.hasValue("lastName"));
// Parse Surgeon (uses Object_Inherit_Surgeon, polymorphic from Object_Inherit_Contact)
in = new ObjectInput(m_surgeon);
root = m_parser.parse(in, table);
assertEquals("Object_Inherit_Surgeon", root.getClassName());
assertEquals("Joshua", root.getValue("firstName"));
assertEquals("Zig", root.getValue("lastName"));
assertEquals("ECG", root.getValue("speciality"));
assertFalse(root.hasValue("middleName"));
table = new MessageTable();
table.addMessage(m_contactNonPolyMsg);
table.addMessage(m_patientMsg);
m_parser.initializeMessageTable(table);
// Parse Patient (uses Object_Inherit_Patient from the table)
in = new ObjectInput(m_patient);
root = m_parser.parse(in, table);
assertEquals("Object_Inherit_Patient", root.getClassName());
assertEquals("Sarah", root.getValue("firstName"));
assertEquals("Johnson", root.getValue("lastName"));
assertTrue(root.hasValue("middleName"));
assertNull(root.getValue("middleName"));
// Parse Surgeon (uses Object_Inherit_Contact_NonPoly from the table)
in = new ObjectInput(m_surgeon);
root = m_parser.parse(in, table);
assertEquals("Object_Inherit_Contact_NonPoly", root.getClassName());
assertEquals("Joshua", root.getValue("firstName"));
assertFalse(root.hasValue("lastName"));
// Parse Contact (uses Object_Inherit_Contact_NonPoly from the table)
in = new ObjectInput(m_contact);
root = m_parser.parse(in, table);
assertEquals("Object_Inherit_Contact_NonPoly", root.getClassName());
assertEquals("Joe", root.getValue("firstName"));
assertFalse(root.hasValue("lastName"));
try
{
table = new MessageTable();
table.addMessage(m_contactMsg);
table.addMessage(m_contactNonPolyMsg);
m_parser.initializeMessageTable(table);
fail("Expected IntegrationException");
}
catch (IntegrationException ex)
{