Package nexj.core.integration.io

Examples of nexj.core.integration.io.ObjectInput


   }

   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"));
View Full Code Here


   public void testParseReferenceInheritance()
   {
      Metaclass phoneClass = getMetadata().getMetaclass("Phone");
      Instance phone;
      ObjectInput in;
      TransferObject phoneRoot, contactRoot;

      phone = (Instance)phoneClass.invoke("new");
      phone.setValue("type", "cell");
      phone.setValue("number", "439-0000");

      // Parse reference to Contact (parsed as Object_Inherit_Contact)
      phone.setValue("contact", m_contact);
      in = new ObjectInput(phone);
      phoneRoot = m_parser.parse(in, m_phoneMsg);

      assertEquals("Object_Inherit_Phone", phoneRoot.getClassName());
      assertEquals("cell", phoneRoot.getValue("type"));
      assertEquals("439-0000", phoneRoot.getValue("number"));
      contactRoot = (TransferObject)phoneRoot.getValue("CONTACT");
      assertEquals("Object_Inherit_Contact", contactRoot.getClassName());
      assertEquals("Joe", contactRoot.getValue("firstName"));
      assertFalse(contactRoot.hasValue("lastName"));

      // Parse reference to Patient (polymorphically parsed as Object_Inherit_Patient)
      phone.setValue("contact", m_patient);
      in = new ObjectInput(phone);
      phoneRoot = m_parser.parse(in, m_phoneMsg);

      assertEquals("Object_Inherit_Phone", phoneRoot.getClassName());
      assertEquals("cell", phoneRoot.getValue("type"));
      assertEquals("439-0000", phoneRoot.getValue("number"));
      contactRoot = (TransferObject)phoneRoot.getValue("CONTACT");
      assertEquals("Object_Inherit_Patient", contactRoot.getClassName());
      assertEquals("Sarah", contactRoot.getValue("firstName"));
      assertEquals("Johnson", contactRoot.getValue("lastName"));
      assertTrue(contactRoot.hasValue("middleName"));
      assertNull(contactRoot.getValue("middleName"));

      // Parse reference to Doctor (polymorphically parsed as Object_Inherit_Contact)
      phone.setValue("contact", m_doctor);
      in = new ObjectInput(phone);
      phoneRoot = m_parser.parse(in, m_phoneMsg);

      assertEquals("Object_Inherit_Phone", phoneRoot.getClassName());
      assertEquals("cell", phoneRoot.getValue("type"));
      assertEquals("439-0000", phoneRoot.getValue("number"));
      contactRoot = (TransferObject)phoneRoot.getValue("CONTACT");
      assertEquals("Object_Inherit_Contact", contactRoot.getClassName());
      assertEquals("Johan", contactRoot.getValue("firstName"));
      assertFalse(contactRoot.hasValue("lastName"));

      // Parse reference to Surgeon (polymorphically parsed as Object_Inherit_Surgeon)
      phone.setValue("contact", m_surgeon);
      in = new ObjectInput(phone);
      phoneRoot = m_parser.parse(in, m_phoneMsg);

      assertEquals("Object_Inherit_Phone", phoneRoot.getClassName());
      assertEquals("cell", phoneRoot.getValue("type"));
      assertEquals("439-0000", phoneRoot.getValue("number"));
      contactRoot = (TransferObject)phoneRoot.getValue("CONTACT");
      assertEquals("Object_Inherit_Surgeon", contactRoot.getClassName());
      assertEquals("Joshua", contactRoot.getValue("firstName"));
      assertEquals("Zig", contactRoot.getValue("lastName"));
      assertEquals("ECG", contactRoot.getValue("speciality"));
      assertFalse(contactRoot.hasValue("middleName"));

      // Try with null "contact"
      phone.setValue("contact", null);
      in = new ObjectInput(phone);

      try
      {
         m_parser.parse(in, m_phoneMsg);
         fail("Expected IntegrationException");
View Full Code Here

      doctor.setValue("licenseNumber", "Lic 01");
      commit();
     
      group = Query.createRead(supportGroupMetaclass, null, null, null, -1, 0, false, Query.SEC_NONE, m_context).read().getInstance(0);
     
      TransferObject tobj = m_parser.parse(new ObjectInput(group), getMessage("Object_SupportGroup"));
      assertEquals("A group", tobj.getValue("name"));
      assertEquals(1, ((List)tobj.getValue("participants")).size());
      assertEquals("Lic 01", ((TransferObject)(((List)tobj.getValue("participants")).get(0))).getValue("licenseNumber"));

      ((InstanceList)group.getValue("participants")).add(contact);
      commit();
  
      try
      {
         m_parser.parse(new ObjectInput(group), getMessage("Object_SupportGroup"));
         fail();
      }
      catch (IntegrationException e)
      {
         assertTrue(e.getCause().getMessage().contains("err.integration.object.partClass"));
View Full Code Here

         null, null, -1, 0, false, Query.SEC_NONE, m_context).read();
     
      for (Iterator itr = instances.iterator(); itr.hasNext(); )
      {
         Instance account = (Instance)itr.next();
         TransferObject accountTobj = m_parser.parse(new ObjectInput(account), getMessage("Object_AccountRecursive"));
         TransferObject contactTobj = (TransferObject)accountTobj.getValue("contact");

         assertTrue(contactTobj.getOID() == ((TransferObject)((TransferObject)contactTobj.getValue("accounts")).getValue("contact")).getOID());
      }
   }
View Full Code Here

TOP

Related Classes of nexj.core.integration.io.ObjectInput

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.