Package nexj.core.rpc

Examples of nexj.core.rpc.TransferObject$Iterator


    */
   public void testBeginTransactionWhenTransient()
   {
      Server server = (Server)m_context.getComponentInstance("Server.Generic");
      Request req = new Request();
      TransferObject tobj = new TransferObject();

      tobj.setClassName("InvocationContextTest");
      tobj.setEventName("create");

      req.addInvocation(tobj);
      req.setCommit(false);

      // This should complete without throwing the err.runtime.transientCommit exception
View Full Code Here


   public void testXMLAdapter2()
   {
      Format format = m_metadata.getFormat("XML");
      Message msg = m_metadata.getMessage("XML_PatientDemographics");
      TransferObject to = ((MessageParser)format.getParser().getInstance(m_context))
         .parse(new StringInput("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<a:Patient xmlns:a=\"http://nexj.com/nexj\" xmlns:b=\"http://nexj.com/nexj/b\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://nexj.com/nexj/integration.xsd\"><player><firstName>My1</firstName><lastName>Test</lastName><id type=\"OHIP\" b:id=\"111222333\"/></player></a:Patient>"), msg);
      TransferObject player = (TransferObject)to.getValue("player");
      List ids = (List)player.getValue("id");
      TransferObject id = (TransferObject)ids.get(0);
      assertEquals(id.getValue("id"), "111222333");
      assertEquals(id.getValue("type"), "OHIP");
      assertEquals(player.getValue("firstName"), "My1");
      assertEquals(player.getValue("lastName"), "Test");
   }
View Full Code Here

   {
      Map messageRegistry = XSDMessageImporterTest.getMessageRegistry(XSDMessageImporterTest.class.getResource("test.xsd"));

      Message tableMessage = (Message)messageRegistry.get("Table");     

      TransferObject table = new TransferObject();
      table.setValue("Association", new TransferObject());
      List rows = new ArrayList();
      TransferObject row = new TransferObject();
      rows.add(row);
      table.setValue("Row", rows);
      row.setValue("name", "row1");
      row.setValue("value", "abcdef");

      Format format = m_metadata.getFormat("XML");
      Writer writer = new StringWriter();
      ((MessageFormatter)format.getFormatter().getInstance(m_context)).format(table, tableMessage, new WriterOutput(writer));

      table = ((MessageParser)format.getParser().getInstance(m_context)).parse(new StringInput(writer.toString()), tableMessage);
      rows = (List)table.getValue("Row");
      row = (TransferObject)rows.get(0);
      assertEquals(row.getValue("value"), "abcdef");
     
      Message recursiveMessage = (Message)messageRegistry.get("recursiveElement");
     
      TransferObject recursiveElement = new TransferObject();
      TransferObject recursiveElement2 = new TransferObject();
      recursiveElement.setValue("recursiveElement2", recursiveElement2);
      recursiveElement2.setValue("recursiveElement", new TransferObject());

      ((MessageFormatter)format.getFormatter().getInstance(m_context))
         .format(recursiveElement, recursiveMessage, new WriterOutput(new StringWriter()));
   }
View Full Code Here

      StringWriter writer = new StringWriter();
      XMLMetadataExporter exporter = new XMLMetadataExporter(writer);
      exporter.exportMessage(tableMessage);
     
      TransferObject table = new TransferObject();
      TransferObject row = new TransferObject();
      table.setValue("a_b", row);
      row.setValue("isConfirmedBySourceOwner", Boolean.FALSE);

      Format format = m_metadata.getFormat("XML");
     
      writer = new StringWriter();
      ((MessageFormatter)format.getFormatter().getInstance(m_context)).format(table, tableMessage, new WriterOutput(writer));
     
      table = ((MessageParser)format.getParser().getInstance(m_context))
         .parse(new StringInput(writer.toString()), tableMessage);
      row = (TransferObject)table.getValue("a_b");
      assertEquals(row.getValue("isConfirmedBySourceOwner"), Boolean.FALSE);
   }
View Full Code Here

      m_context = null;
   }

   public void testTwoMessagesToCollection()
   {
      TransferObject msg = new TransferObject("MsgCol", 2);
      TransferObject tobj = new TransferObject(2);

      tobj.setValue("s", "q");
      tobj.setValue("n", new Integer(1));

      msg.setValue("a", tobj);

      tobj = new TransferObject(2);

      tobj.setValue("s", "r");
      tobj.setValue("n", new Integer(2));
     
      msg.setValue("b", tobj);

      TransferObject res = m_tf.transform(msg, m_metadata.getTransformation("2MsgToCol"));

      assertEquals("MsgCol", res.getClassName());
      assertEquals(1, res.getValueCount());
     
      List list = (List)res.getValue("c");

      assertEquals(2, list.size());

      tobj = (TransferObject)list.get(0);
View Full Code Here

      assertEquals(new Integer(2), tobj.getValue("n"));
   }
  
   public void testNullAttributes()
   {
      TransferObject msg = new TransferObject("MsgCol", 2);
      TransferObject tobj = new TransferObject(2);

      tobj.setValue("s", "q");
      tobj.setValue("n", null);
      msg.setValue("a", tobj);

      TransferObject res = m_tf.transform(msg, m_metadata.getTransformation("NullAttributes"));

      assertEquals("MsgCol", res.getClassName());
      assertEquals(2, res.getValueCount());

      tobj = (TransferObject)res.getValue("a");

      assertEquals(2, tobj.getValueCount());
      assertEquals("maybe null", tobj.getValue("s"));
      assertEquals(new Integer(0), tobj.getValue("n"));

      tobj = (TransferObject)res.getValue("b");

      assertEquals(1, tobj.getValueCount());
      assertEquals("not null", tobj.getValue("s"));
      assertNull(tobj.findValue("n"));
   }
View Full Code Here

      assertNull(tobj.findValue("n"));
   }

   public void testDefaultAttributes()
   {
      TransferObject msg = new TransferObject("MsgCol", 2);
      TransferObject tobj = new TransferObject(2);

      msg.setValue("a", tobj);

      TransferObject res = m_tf.transform(msg, m_metadata.getTransformation("DefaultAttributes"));

      assertEquals("MsgCol", res.getClassName());
      assertEquals(2, res.getValueCount());

      tobj = (TransferObject)res.getValue("a");

      assertEquals(2, tobj.getValueCount());
      assertNull(tobj.getValue("s"));
      assertEquals(new Integer(1), tobj.getValue("n"));

      List list = (List)res.getValue("c");

      assertEquals(1, list.size());

      tobj = (TransferObject)list.get(0);
View Full Code Here

      assertEquals("q", tobj.getValue("s"));
   }
  
   public void testTransformManyToOne()
   {
      TransferObject msg = new TransferObject("MsgCol", 2);
      TransferObject tobj = new TransferObject(2);

      tobj.setValue("s", "q");
      tobj.setValue("n", new Integer(1));

      msg.setValue("a", tobj);

      tobj = new TransferObject(2);

      tobj.setValue("s", "r");
      tobj.setValue("n", new Integer(2));
     
      msg.setValue("b", tobj);

      TransferObject res = m_tf.transform(msg, m_metadata.getTransformation("2MsgToColSimple"));

      assertEquals("MsgCol", res.getClassName());
      assertEquals(1, res.getValueCount());
     
      List list = (List)res.getValue("c");

      assertEquals(2, list.size());

      tobj = (TransferObject)list.get(0);
View Full Code Here

   }
  
   public void testTransformPrimitives()
   {
      // build source message
      TransferObject msg = new TransferObject("TransformTestMsg", 4);
      TransferObject msg1 = null;
      ArrayList col = null;
      ArrayList col1 = null;
     
      msg.setValue("primitive", new Integer(0));
      col = new ArrayList(2);
      col.add(new Integer(4));
      col.add(new Integer(5));
      msg.setValue("primitiveCollection", col);
     
      msg1 = new TransferObject(2);
      msg1.setValue("primitive", new Integer(10));
      col = new ArrayList(2);
      col.add(new Integer(14));
      col.add(new Integer(15));
      msg1.setValue("primitiveCollection", col);
     
      msg.setValue("message", msg1);
     
      col1 = new ArrayList(2);
     
      msg1 = new TransferObject(2);
      msg1.setValue("primitive", new Integer(20));
      col = new ArrayList(2);
      col.add(new Integer(24));
      col.add(new Integer(25));
      msg1.setValue("primitiveCollection", col);
     
      col1.add(msg1);
     
      msg1 = new TransferObject(2);
      msg1.setValue("primitive", new Integer(30));
      col = new ArrayList(2);
      col.add(new Integer(34));
      col.add(new Integer(35));
      msg1.setValue("primitiveCollection", col);
     
      col1.add(msg1);
     
      msg.setValue("messageCollection", col1);

      // transform message
      TransferObject res = m_tf.transform(msg, m_metadata.getTransformation("MapPrimitive"));

      // validate result message
      assertEquals("TransformTestMsg", res.getClassName());
      assertEquals(4, res.getValueCount());
     
      assertEquals(new Integer(0), res.getValue("primitive"));
      col = (ArrayList)res.getValue("primitiveCollection");
      assertEquals(4, col.size());
      assertEquals(new Integer(0), col.get(0));
      assertEquals(new Integer(1), col.get(1));
      assertEquals(new Integer(2), col.get(2));
      assertEquals(new Integer(3), col.get(3));
     
      msg = (TransferObject)res.getValue("message");
     
      assertEquals(2, msg.getValueCount());
     
      assertEquals(new Integer(15), msg.getValue("primitive"));
      col = (ArrayList)msg.getValue("primitiveCollection");
     
      assertEquals(4, col.size());
      assertEquals(new Integer(14), col.get(0));
      assertEquals(new Integer(14), col.get(1));
      assertEquals(new Integer(15), col.get(2));
      assertEquals(new Integer(15), col.get(3));

      col = (ArrayList)res.getValue("messageCollection");
      assertEquals(2, col.size());
     
      msg = (TransferObject)col.get(0);
      assertEquals(2, msg.getValueCount());
     
View Full Code Here

   }
  
   public void testTransformWithPrimitiveIndexing()
   {
      // build source message
      TransferObject msg = new TransferObject("TransformTestMsg", 4);
      TransferObject msg1 = null;
      ArrayList col = null;
     
      col = new ArrayList(2);
     
      msg1 = new TransferObject(2);
      msg1.setValue("primitive", Primitive.createInteger(1));
      msg1.setValue("primitive2", Primitive.createInteger(1));
     
      col.add(msg1);
     
      msg1 = new TransferObject(2);
      msg1.setValue("primitive", Primitive.createInteger(1));
      msg1.setValue("primitive2", Primitive.createInteger(2));
     
      col.add(msg1);
     
      msg.setValue("messageCollection", col);

      // transform message
      TransferObject res = m_tf.transform(msg, m_metadata.getTransformation("MapWithPrimitiveIndexing"));

      // validate result message
      assertEquals("TransformTestMsg", res.getClassName());
      assertEquals(1, res.getValueCount());

      col = (ArrayList)res.getValue("messageCollection");
      assertEquals(4, col.size());
     
      msg = (TransferObject)col.get(0);
      assertEquals(2, msg.getValueCount());
     
View Full Code Here

TOP

Related Classes of nexj.core.rpc.TransferObject$Iterator

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.