Package nexj.core.rpc

Examples of nexj.core.rpc.Response


                       Pair.list("c", "d"));
      m_request.addInvocation(
         contact, "invokeEv", new Object[]{new Long(-1), new Double(Math.E)}, Pair.list("e", "f"));
      m_request.addFilter(contact);

      m_response = new Response();
      m_response.addResult(contact);
      m_response.addResult(address);

      ArrayList eventList = new ArrayList();
View Full Code Here


   {
      m_marshaller.serialize(m_response, m_writer);
      XMLUtil.parse(new StringReader(m_writer.toString()), m_xsdMap); // validate to XSD

      StringReader reader = new StringReader(m_writer.toString());
      Response resp = (Response)m_unmarshaller.deserialize(reader);

      assertEquals(2, resp.getResultCount());

      // remove all pointer references,
      // objects are going to be different due to being unmarshalled from different branches of the
      // XML tree (i.e. first argument and second argument blocks)
      // XMLMarshaller is hardcoded to marshal List as Object[] for compatibility with MS.NET
      assertEqualsPointerless(
         ((List)((TransferObject)resp.getResult(0)).getValue("addresses")).get(1),
         resp.getResult(1));

      assertEquals(1, resp.getEventCount());
      List eventList = (List)resp.getEvent(0);

      // remove all pointer references,
      // objects are going to be different due to being unmarshalled from different branches of the
      // XML tree (i.e. first event and second event blocks)
      assertEqualsPointerless(eventList.get(0), eventList.get(1));
View Full Code Here

   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
         + "\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><objects xsi:type=\"User\"><"
View Full Code Here

      StringReader reader = new StringReader("<Change-Request xmlns=\"" + XML.NS_URI_TNS
         + "\" 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

      StringWriter writer = new StringWriter();
      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

      XMLUnmarshaller unmarshaller = new XMLUnmarshaller(new InvocationContext(Repository.getMetadata()));
      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

      XMLUnmarshaller unmarshaller = new XMLUnmarshaller(new InvocationContext(Repository.getMetadata()));
      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

      StringWriter writer = new StringWriter();
      XMLUnmarshaller unmarshaller = new XMLUnmarshaller(new InvocationContext(Repository.getMetadata()));
      StringReader reader = new StringReader("<Read-Request xmlns=\"" + XML.NS_URI_TNS + "\"><class>Patient</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("Patient");
      TransferObject tobj2 = new TransferObject("Doctor");

      tobj2.setOID(OID.fromBinary(Binary.parse("1000000000000010008000BEEF0000000A")));
      tobj.setValue("doctor", tobj2);
      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

      Node root = XMLUtil.parse(new StringReader(writer.toString())).getFirstChild();

      assertEquals(XML.BASE_PREFIX + "Read-Response", root.getNodeName());
      assertEquals(1, root.getChildNodes().getLength());
      assertEquals("item", root.getChildNodes().item(0).getNodeName());
      assertEquals(1, root.getChildNodes().item(0).getAttributes().getLength());
      assertEquals("Patient",
                   root
                      .getChildNodes()
                         .item(0)
                            .getAttributes()
                               .getNamedItem(XML.XSI_NS + ":type")
                                  .getNodeValue());
      assertEquals(3, root.getChildNodes().item(0).getChildNodes().getLength());

      assertNotNull(XMLUtil.findChildElement(root.getChildNodes().item(0),
                                             XML.BASE_PREFIX + "oid"));
      assertNotNull(XMLUtil.findChildElement(root.getChildNodes().item(0),
                                             XML.BASE_PREFIX + "version"));
      assertNull(XMLUtil
                    .findChildElement(root.getChildNodes().item(0), "doctor")
                       .getAttributes()
                          .getNamedItem(XML.XSI_NS + ":type"));

      writer.getBuffer().setLength(0);
      reader = new StringReader("<Read-Request xmlns=\"" + XML.NS_URI_TNS + "\"><class>Patient</class>"
         + "<attributes>(fullName name)</attributes><where></where><orderBy></orderBy><count>8</count>"
         + "<offset>0</offset></Read-Request>");
      response = new Response();
      tobj = new TransferObject("User");
      tobj2 = new TransferObject("Doctor");

      tobj2.setOID(OID.fromBinary(Binary.parse("1000000000000010008000BEEF0000000A")));
      tobj.setValue("contact", tobj2);
      response.addResult(Arrays.asList(new Object[]{tobj}));
      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

   }

   public void testMarshalValidateMetaclass() throws MarshallerException, IOException
   {
      StringWriter writer = new StringWriter();
      Response response = new Response();
      TransferObject tobj = new TransferObject("Contact"); // valid Metaclass object

      tobj.setValue("firstName", "Name First");
      tobj.setValue("lastName", null);
      tobj.setValue("customKey", "Key Custom");
      response.addResult(tobj); // need to marshal inside a Response since need predefined element

      m_marshaller.serialize(response, writer);

      Document rsp = XMLUtil.parse(new StringReader(writer.toString()), m_xsdMap);//validate to XSD
      Node root = rsp.getFirstChild();
View Full Code Here

   /**
    * Constructs the server with an empty response.
    */
   public MockServer()
   {
      m_response = new Response();
   }
View Full Code Here

TOP

Related Classes of nexj.core.rpc.Response

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.