Package nexj.core.rpc

Examples of nexj.core.rpc.TransferObject$Iterator


   public void testBasicResponse() throws IOException
   {
      StringWriter writer = new StringWriter();
      XMLUnmarshaller unmarshaller = new XMLUnmarshaller(new InvocationContext(Repository.getMetadata()));
      Response response = new Response();
      TransferObject tobj = new TransferObject("User");

      tobj.setValue("e", new Double(2.71828183));
      tobj.setValue("privilegeSet", new Integer(42));
      tobj.setValue("name", "Name");
      response.addResult(tobj);

      writer.getBuffer().setLength(0);
      XMLChangeRequest request = (XMLChangeRequest)unmarshaller.deserialize(
         new StringReader("<Change-Request xmlns=\"" + XML.NS_URI_TNS
View Full Code Here


         + "\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><objects x" + "si:type=\"Principal\"><"
         + XML.BASE_PREFIX + "oid>10e8359492f25f4be49109b9979e684ff3</" + XML.BASE_PREFIX
         + "oid><" + XML.BASE_PREFIX + "event>welcome</" + XML.BASE_PREFIX
         + "event><name>fullname</name></objects><attributes>(firstName name)</attributes></Change-Request>");
      Response response = new Response();
      TransferObject tobj = new TransferObject("User");

      tobj.setValue("firstName", "FName");
      tobj.setValue("name", "fullName");
      response.addResult(tobj);
      XMLChangeRequest request = (XMLChangeRequest)unmarshaller.deserialize(reader);

      m_marshaller.serialize(request.invoke(new MockServer(response)), writer);
      XMLUtil.parse(new StringReader(writer.toString()), m_xsdMap); // validate to XSD
View Full Code Here

                   "20000000a80000007365696e66656c64" +
                   "2f636861726163746572732f6a657272" +
                   "792e747874504b050600000000040004" +
                   "0010010000f500000000000a");

      TransferObject root = m_parser.parse(new ObjectInput(zipBin), m_message);
      List filesList = (List)root.getValue("files");

      assertEquals("Zip_AllMapped", root.getClassName());
      assertNotNull(filesList);
      assertEquals(4, filesList.size());

      TransferObject file;

      file = (TransferObject)filesList.get(0);
      assertEquals("seinfeld" + SysUtil.FILE_SEP, file.getValue("fileName"));
      assertTrue(((Boolean)file.getValue("isDirectory")).booleanValue());
      assertEquals(0, ((Long)file.getValue("fileSize")).longValue());
      assertNull(file.getValue("data"));

      file = (TransferObject)filesList.get(1);
      assertEquals("seinfeld" + SysUtil.FILE_SEP + "characters"  + SysUtil.FILE_SEP, file.getValue("fileName"));
      assertTrue(((Boolean)file.getValue("isDirectory")).booleanValue());
      assertEquals(0, ((Long)file.getValue("fileSize")).longValue());
      assertNull(file.getValue("data"));

      file = (TransferObject)filesList.get(2);
      assertEquals("seinfeld" + SysUtil.FILE_SEP + "characters" + SysUtil.FILE_SEP + "george.txt", file.getValue("fileName"));
      assertFalse(((Boolean)file.getValue("isDirectory")).booleanValue());
      assertEquals(19, ((Long)file.getValue("fileSize")).longValue());
      assertEquals(new Binary("Contents of george.".getBytes("UTF-8")), file.getValue("data"));

      file = (TransferObject)filesList.get(3);
      assertEquals("seinfeld" + SysUtil.FILE_SEP + "characters" + SysUtil.FILE_SEP + "jerry.txt", file.getValue("fileName"));
      assertFalse(((Boolean)file.getValue("isDirectory")).booleanValue());
      assertEquals(18, ((Long)file.getValue("fileSize")).longValue());
      assertEquals(new Binary("Contents of jerry.".getBytes("UTF-8")), file.getValue("data"));
   }
View Full Code Here

      XMLUnmarshaller unmarshaller = new XMLUnmarshaller(new InvocationContext(Repository.getMetadata()));
      StringReader reader = new StringReader("<Read-Request xmlns=\"" + XML.NS_URI_TNS + "\"><class>Principal</class>"
         + "<attributes>(fullName name)</attributes><where></where><orderBy></orderBy><count>8</count>"
         + "<offset>0</offset></Read-Request>");
      Response response = new Response();
      TransferObject tobj = new TransferObject("User");

      tobj.setValue("fullName", "FName");
      tobj.setValue("name", null);
      response.addResult(Arrays.asList(new Object[]{tobj}));
      XMLReadRequest request = (XMLReadRequest)unmarshaller.deserialize(reader);

      m_marshaller.serialize(request.invoke(new MockServer(response)), writer);
      XMLUtil.parse(new StringReader(writer.toString()), m_xsdMap); // validate to XSD
View Full Code Here

      StringReader reader = new StringReader("<Principal-Change-Request xmlns=\"" + XML.NS_URI_TNS + "\"><objects><"
         + XML.BASE_PREFIX + "oid>10e8359492f25f4be49109b9979e684ff3</" + XML.BASE_PREFIX
         + "oid><" + XML.BASE_PREFIX + "event>welcome</" + XML.BASE_PREFIX
         + "event><name>fullname</name></objects><attributes>(fullName name)</attributes></Principal-Change-Request>");
      Response response = new Response();
      TransferObject tobj = new TransferObject("User");

      tobj.setValue("fullName", "FName");
      tobj.setValue("name", "Name");
      response.addResult(tobj);
      XMLChangeRequest request = (XMLChangeRequest)unmarshaller.deserialize(reader);

      m_marshaller.serialize(request.invoke(new MockServer(response)), writer);
      XMLUtil.parse(new StringReader(writer.toString()), m_xsdMapBasic); // validate to XSD
View Full Code Here

   public void testTransformParsePrimitive()
   {
      Message csvMessage = m_metadata.getMessage("CSVTestSuiteResult");
      MessageParser csvParser = (MessageParser)csvMessage.getFormat().getParser().getInstance(m_context);
      StringInput in;
      TransferObject root, result, sub;
      List list;

      in = new StringInput("date,status,result\n" +
         "2009-09-23T17:34:00,PASS,\"<XMLTestResult seed=\\\"5\\\"><a>aValue</a></XMLTestResult>\"\n" +
         "2009-09-23T17:36:00,FAIL,\"<XMLTestResult><a>aValue2</a><b>bValue</b></XMLTestResult>\"\n"
         );

      root = csvParser.parse(in, csvMessage);
      assertEquals("CSVTestSuiteResult", root.getClassName());
      assertEquals(2, ((List)root.getValue("rows")).size());

      result = m_tf.transform(root, m_metadata.getTransformation("CSVTestSuiteResultToXMLTestSuiteResult"));

      assertEquals("XMLTestSuiteResult", result.getClassName());
      list = (List)result.getValue("tests");
      assertEquals(2, list.size());

      sub = (TransferObject)list.get(0);
      assertEquals(Primitive.toTimestamp("2009-09-23T17:34:00"), sub.getValue("date"));
      assertEquals("PASS", sub.getValue("status"));
      sub = (TransferObject)sub.getValue("data");
      assertEquals("XMLTestResult", sub.getClassName());
      assertEquals("5", sub.getValue("seed"));
      assertEquals("aValue", sub.getValue("a"));
      assertFalse(sub.hasValue("b"));

      sub = (TransferObject)list.get(1);
      assertEquals(Primitive.toTimestamp("2009-09-23T17:36:00"), sub.getValue("date"));
      assertEquals("FAIL", sub.getValue("status"));
      sub = (TransferObject)sub.getValue("data");
      assertEquals("XMLTestResult", sub.getClassName());
      assertEquals("bValue", sub.getValue("b"));
      assertEquals("aValue2", sub.getValue("a"));
      assertFalse(sub.hasValue("seed"));

      // Try using a message that is referred to by a message with no format
      TransferObject outer = new TransferObject(1);

      outer.setValue("csv", root);
      result = m_tf.transform(outer, m_metadata.getTransformation("TestSuiteResult"));

      assertEquals("MultiFormatReferrer", result.getClassName());
      assertFalse(result.hasValue("csv"));
      result = (TransferObject)result.getValue("xml");
View Full Code Here

      StringReader reader = new StringReader("<Principal-Read-Request xmlns=\"" + XML.NS_URI_TNS
         + "\"><class>User-test</class>"
         + "<attributes>(fullName)</attributes><where></where><orderBy></orderBy><count>8</count>"
         + "<offset>0</offset></Principal-Read-Request>");
      Response response = new Response();
      TransferObject tobj = new TransferObject("User");
     
      tobj.setValue("fullName", "FName");
      tobj.setValue("name", "Name");
      response.addResult(Arrays.asList(new Object[]{tobj}));
      XMLReadRequest request = (XMLReadRequest)unmarshaller.deserialize(reader);

      m_marshaller.serialize(request.invoke(new MockServer(response)), writer);
      XMLUtil.parse(new StringReader(writer.toString()), m_xsdMapBasic); // validate to XSD
View Full Code Here

  
   public void testHL7Adapter()
   {
      Format format = m_metadata.getFormat("HL7");
      Message msg = m_metadata.getMessage("HL7_25_ADT_A04");
      TransferObject to = ((MessageParser)format.getParser().getInstance(m_context))
         .parse(new StringInput("MSH|^~\\&|||||20050326012305.528+0100||ADT^A04|1|P|2.5||||||\rEVN|A04||||||\rPID|||1234567890^^^&OHIP||Test^Joe||19800102|M||U|123 45th St^^Toronto^ON^A1B2C3^Canada^H^||(416) 123-4567|(416) 456-7890|||||||||||||||||||||||||\r"), msg);
      TransferObject patientID = (TransferObject)to.getValue("patientIdentification");

      Timestamp birthDate = (Timestamp)((TransferObject)patientID.getValue("dateTimeOfBirth")).getValue("time");
      Calendar calendar = Calendar.getInstance();
      calendar.setTime(birthDate);
      assertEquals(calendar.get(Calendar.YEAR), 1980);
      assertEquals(calendar.get(Calendar.MONTH), 1);
      assertEquals(calendar.get(Calendar.DAY_OF_MONTH), 1);

      TransferObject name = (TransferObject)patientID.getValue("patientName");
      assertEquals("Joe", name.getValue("givenName"));
      assertEquals(((TransferObject)name.getValue("familyName")).getValue("surname"), "Test");
   }
View Full Code Here

      assertEquals(((TransferObject)name.getValue("familyName")).getValue("surname"), "Test");
   }

   public void testObjectAdapter()
   {
      TransferObject pat = new TransferObject();
      TransferObject pl = new TransferObject();
      pl.setValue("firstName", "My1");
      pl.setValue("lastName", "Test");
      List ids = new ArrayList();
      TransferObject id = new TransferObject();
      id.setValue("type", "OHIP");
      id.setValue("id", "111222333");
      ids.add(id);
      pl.setValue("ids", ids);
      pat.setValue("player", pl);
      Format format = m_metadata.getFormat("Object");
      Message msg = m_metadata.getMessage("Object_PatientDemographics");
      ObjectOutput out = new ObjectOutput();
     
      ((MessageFormatter)format.getFormatter().getInstance(m_context)).format(pat, msg, out);
     
      TransferObject patCompare = ((MessageParser)format.getParser().getInstance(m_context))
         .parse(new ObjectInput(out.getObject()), msg);
      TransferObject plCompare = (TransferObject)patCompare.getValue("player");
      List idsCompare = (List)plCompare.getValue("ids");
      TransferObject idCompare = (TransferObject)idsCompare.get(0);
      assertEquals("OHIP", idCompare.getValue("type"));
      assertEquals("111222333", idCompare.getValue("id"));
      assertEquals(plCompare.getValue("firstName"), "My1");
      assertEquals(plCompare.getValue("lastName"), "Test");
   }
View Full Code Here

      assertEquals(plCompare.getValue("lastName"), "Test");
   }
  
   public void testXMLAdapter()
   {
      TransferObject pat = new TransferObject();
      TransferObject pl = new TransferObject();
      pl.setValue("firstName", "My1");
      pl.setValue("lastName", "Test");
      List ids = new ArrayList();
      TransferObject id = new TransferObject();
      id.setValue("type", "OHIP");
      id.setValue("id", "111222333");
      ids.add(id);
      pl.setValue("id", ids);
      pat.setValue("player", pl);
      Format format = m_metadata.getFormat("XML");
      Message msg = m_metadata.getMessage("XML_PatientDemographics");
      Writer writer = new StringWriter();

      ((MessageFormatter)format.getFormatter().getInstance(m_context)).format(pat, msg, new WriterOutput(writer));
     
      TransferObject patCompare = ((MessageParser)format.getParser().getInstance(m_context))
         .parse(new StringInput(writer.toString()), msg);
      TransferObject plCompare = (TransferObject)patCompare.getValue("player");
      List idsCompare = (List)plCompare.getValue("id");
      TransferObject idCompare = (TransferObject)idsCompare.get(0);
      assertEquals(idCompare.getValue("id"), "111222333");
      assertEquals(idCompare.getValue("type"), "OHIP");
      assertEquals(plCompare.getValue("firstName"), "My1");
      assertEquals(plCompare.getValue("lastName"), "Test");
   }
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.