Package nexj.core.rpc

Examples of nexj.core.rpc.Request$Invocation


      instance.setValue("principal", sUser);
     
      if (accessor instanceof Metaclass)
      {
         TransferObject tobj = new TransferObject(((Metaclass)accessor).getName(), 0);
         Request request = new Request();

         tobj.setEventName(event.getName());
         request.addInvocation(tobj);

         try
         {
            instance.setValue("data", Binary.fromObject(request));
         }
View Full Code Here


         }
      });

      int nReqCount = Integer.parseInt(getProperty("req.count", "1"));

      final Request request = new Request();
      TransferObject tobj = new TransferObject();
     
      tobj.setClassName("TestMessage");
      tobj.setEventName("runTest");
     
      request.addInvocation(tobj);
      request.setAsync(StringUtil.parseBoolean(getProperty("async", "0")));

      for (int nReq = 0; nReq < nReqCount; ++ nReq)
      {
         Object response = client.invoke(new URI(getProperty("url", "http://localhost:8080/nexj/text")), HTTP.METHOD_POST,
            new HTTPClient.RequestHandler()
View Full Code Here

      XMLChangeRequest changeRequest = (XMLChangeRequest)unmarshaller.deserialize(reader);
      MockServer server = new MockServer();

      changeRequest.invoke(server);

      Request request = server.getRequest();
      Request.Invocation action = request.getInvocation(0);

      assertEquals(1, request.getInvocationCount());
      assertNull(action.getEventName());
      assertEquals("User", request.getObject(0).getClassName());
      assertEquals("welcome", request.getObject(0).getEventName());
      assertEquals(OID.fromBinary(Binary.parse("10e8359492f25f4be49109b9979e684ff3")),
         request.getObject(0).getOID());
      assertEquals(1, request.getObject(0).getValueCount());
      assertEquals("fullname", request.getObject(0).findValue("fullName"));
      assertEquals(parser.parse(new StringReader("(password)"), null), action.getAttributes());
      assertEquals(0, request.getFilterCount());

      assertNull(changeRequest.getMetaclass());
   }
View Full Code Here

      XMLReadRequest readRequest = (XMLReadRequest)unmarshaller.deserialize(reader);
      MockServer server = new MockServer(new Object[1]);

      readRequest.invoke(server);

      Request request = server.getRequest();
      Request.Invocation action = request.getInvocation(0);

      assertEquals(1, request.getInvocationCount());
      assertEquals("User-test", request.getObject(0).getClassName());
      assertNull(request.getObject(0).getEventName());
      assertNull(request.getObject(0).getOID());
      assertEquals("read", action.getEventName());
      assertEquals(6, action.getArguments().length);
      assertEquals(parser.parse(new StringReader("(fullName)"), null), action.getArguments()[0]);
      assertNull(action.getArguments()[1]);
      assertNull(action.getArguments()[2]);
      assertEquals(8, ((Integer)action.getArguments()[3]).intValue());
      assertEquals(0, ((Integer)action.getArguments()[4]).intValue());
      assertEquals(Boolean.FALSE, action.getArguments()[5]);
      assertEquals(0, request.getFilterCount());

      assertNull(readRequest.getMetaclass());
   }
View Full Code Here

      XMLChangeRequest changeRequest = (XMLChangeRequest)unmarshaller.deserialize(reader);
      MockServer server = new MockServer();

      changeRequest.invoke(server);

      Request request = server.getRequest();
      Request.Invocation action = request.getInvocation(0);

      assertEquals(1, request.getInvocationCount());
      assertEquals("User", request.getObject(0).getClassName());
      assertEquals("welcome", request.getObject(0).getEventName());
      assertEquals(OID.fromBinary(Binary.parse("10e8359492f25f4be49109b9979e684ff3")),
                   request.getObject(0).getOID());
      assertEquals(1, request.getObject(0).getValueCount());
      assertEquals("fullname", request.getObject(0).findValue("fullName"));
      assertEquals(0, request.getFilterCount());
      assertNull(action.getEventName());
      assertEquals(parser.parse(new StringReader("(password)"), null), action.getAttributes());
      assertEquals("User", changeRequest.getMetaclass().getName());
   }
View Full Code Here

      XMLReadRequest readRequest = (XMLReadRequest)unmarshaller.deserialize(reader);
      MockServer server = new MockServer(new Object[1]);

      readRequest.invoke(server);

      Request request = server.getRequest();
      Request.Invocation action = request.getInvocation(0);

      assertEquals(1, request.getInvocationCount());
      assertEquals("User-test", request.getObject(0).getClassName());
      assertNull(request.getObject(0).getEventName());
      assertNull(request.getObject(0).getOID());
      assertEquals("read", action.getEventName());
      assertEquals(6, action.getArguments().length);
      assertEquals(parser.parse(new StringReader("(fullName)"), null), action.getArguments()[0]);
      assertNull(action.getArguments()[1]);
      assertNull(action.getArguments()[2]);
      assertEquals(8, ((Integer)action.getArguments()[3]).intValue());
      assertEquals(0, ((Integer)action.getArguments()[4]).intValue());
      assertEquals(Boolean.FALSE, action.getArguments()[5]);
      assertEquals(0, request.getFilterCount());
      assertEquals("User", readRequest.getMetaclass().getName());
   }
View Full Code Here

         "<listtyped>abc</listtyped><listtyped>def</listtyped>" +
         "</" + sElement + ">");

      ((XMLInvocationRequest)unmarshaller.deserialize(reader)).invoke(server);

      Request request = server.getRequest();

      assertNotNull(request);
      assertEquals(1, request.getInvocationCount());

      Request.Invocation action = request.getInvocation(0);
      TransferObject tobj = action.getObject();
      Object[] argArray = action.getArguments();

      assertEquals(publicEv.getName(), action.getEventName());
      assertEquals(publicEv.getArgumentCount(), argArray.length);
      assertTrue(argArray[0] instanceof BigDecimal);
      assertEquals(3.1415926535897932384626433832795, ((BigDecimal)argArray[0]).doubleValue(), 0);
      assertTrue(argArray[1] instanceof Timestamp);
      assertEquals(ts.getTime(), ((Timestamp)argArray[1]).getTime());
      assertEquals(Primitive.createInteger(42), argArray[2]);
      assertTrue(argArray[3] instanceof List);
      assertEquals(2, ((List)argArray[3]).size());
      assertEquals("abc", ((List)argArray[3]).get(0));
      assertEquals("def", ((List)argArray[3]).get(1));
      assertEquals(metaclass.getName(), tobj.getClassName());
      assertNull(tobj.getEventName());
      assertNull(tobj.getOID());
      assertEquals(1, tobj.getValueCount());
      assertEquals("test", tobj.findValue(attr.getName()));

      // test static bound event
      sElement = XSDGenerator.computeElementName(staticEv);
      reader = new StringReader(
         "<" + sElement + " xmlns:xs='http://www.w3.org/2001/XMLSchema'" +
         " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" +
         " xmlns:tns='" + XML.NS_URI_TNS + "'" +
         " xmlns='" + XML.NS_URI_TNS + '/' + metaclass.getName() + "'>" +
         "<_instance><tns:" + attr.getName() + ">test</tns:" + attr.getName() + "></_instance>" +
         "<untyped xsi:type='xs:decimal'>3.1415926535897932384626433832795</untyped>" +
         "<anytyped xsi:type='xs:dateTime'>1234-05-06T07:08:09</anytyped>" +
         "<inttyped>42</inttyped>" +
         "<listtyped>abc</listtyped><listtyped>def</listtyped>" +
         "</" + sElement + ">");

      try
      {
         unmarshaller.deserialize(reader);
         fail(); // SOAPUnmarshallerException expected
      }
      catch (SOAPUnmarshallerException e)
      {
         assertEquals("err.rpc.soap.element", e.getErrorCode());
      }

      // test static event
      sElement = XSDGenerator.computeElementName(staticEv);
      reader = new StringReader(
         "<" + sElement + " xmlns:xs='http://www.w3.org/2001/XMLSchema'" +
         " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" +
         " xmlns:tns='" + XML.NS_URI_TNS + "'" +
         " xmlns='" + XML.NS_URI_TNS + '/' + metaclass.getName() + "'>" +
         "<untyped xsi:type='xs:decimal'>3.1415926535897932384626433832795</untyped>" +
         "<anytyped xsi:type='xs:dateTime'>1234-05-06T07:08:09</anytyped>" +
         "<inttyped>42</inttyped>" +
         "<listtyped><tns:item>abc</tns:item><tns:item>def</tns:item></listtyped>" +
         "<listtyped><tns:item>ghi</tns:item><tns:item>jkl</tns:item></listtyped>" +
         "</" + sElement + ">");
      ((XMLInvocationRequest)unmarshaller.deserialize(reader)).invoke(server);
      request = server.getRequest();
      assertNotNull(request);
      assertEquals(1, request.getInvocationCount());
      action = request.getInvocation(0);
      tobj = action.getObject();
      assertEquals(staticEv.getName(), action.getEventName());
      argArray = action.getArguments();
      assertEquals(5, argArray.length); // untyped + anytyped + inttyped + 2*listtyped
      assertTrue(argArray[0] instanceof BigDecimal);
View Full Code Here

    *    testCanUnitTestsDetectImproperCommitOfATransaction must PASS for this test result to be valid.
    */
   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
      server.invoke(req);
   }
View Full Code Here

      m_xsdMapBasic.put(XML.NS_URI_TNS, m_tmpTNSBasicXSD.toURL());
      m_xsdMapBasic.put(XML.NS_URI_XML, XML_NAMESPACE_URL);
      m_xsdMapBasic.put(XML.ENV_URI, m_tmpSOAPXSD.toURL());

      m_request = new Request();

      TransferObject contact = new TransferObject();

      contact.setOID(new OID(new Object[]{"123"}));
View Full Code Here

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

      StringReader reader = new StringReader(m_writer.toString());
      Request req = (Request)m_unmarshaller.deserialize(reader);

      assertEquals("http://www.nexjsystems.com/ns/test", req.getNamespace());
      assertEquals("10", req.getVersion());
      assertEquals(true, req.isAsync());
      assertEquals(true, req.isCommit());
      assertEquals("bg_BG_SF", req.getLocale().toString());
      assertEquals("AST", req.getTimeZone().getID());
      assertEquals(4, req.getInvocationCount());
      assertEquals(1, req.getFilterCount());

      TransferObject contact = req.getObject(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 argument and first filter blocks)
      assertEqualsPointerless(contact, req.getFilter(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 argument and first filter blocks)
      assertEqualsPointerless(contact, req.getObject(1));

      Request.Invocation action = req.getInvocation(0);

      assertTrue(contact == action.getObject());
      assertNull(action.getEventName());
      assertNull(action.getAttributes());

      Pair pair = req.getInvocation(1).getAttributes();

      assertEquals("a", pair.getHead());
      assertEquals("b", pair.getNext().getHead());
      assertNull(pair.getNext().getNext());
     
      Object[] params = req.getInvocation(2).getArguments();
      assertEquals(3, params.length);
      assertTrue(params[0] instanceof Integer);
      assertEquals(42, ((Integer)params[0]).intValue());
      assertTrue(params[1] instanceof Double);
      assertEquals(Math.PI, ((Double)params[1]).doubleValue(), 0);
      assertTrue(params[2] instanceof String);
      assertEquals("Hello World!", params[2]);

      action = req.getInvocation(3);
      assertEquals("invokeEv", action.getEventName());
      assertEquals("update", action.getObject().getEventName());
      params = action.getArguments();
      assertEquals(2, params.length);
      assertTrue(params[0] instanceof Long);
      assertEquals(-1, ((Long)params[0]).intValue());
      assertTrue(params[1] instanceof Double);
      assertEquals(Math.E, ((Double)params[1]).doubleValue(), 0);
      pair = action.getAttributes();
      assertEquals("e", pair.getHead());
      assertEquals("f", pair.getNext().getHead());
      assertNull(pair.getNext().getNext());

      OID oid = contact.getOID();

      assertEquals(1, oid.getCount());
      assertEquals("123", oid.getValue(0));

      assertEquals("Contact-test", contact.getClassName());
      assertEquals("update", contact.getEventName());
      assertEquals(12345, contact.getVersion());
      assertEquals(24, contact.getValueCount());
      assertEquals("Java", contact.getValue("firstName"));
      assertEquals("Kava", contact.getValue("lastName"));
      assertNull(contact.getValue("null"));
      assertSame(contact, contact.getValue("self"));
      assertEquals(new Integer(1), contact.getValue("integer"));
      assertEquals(new Long(2), contact.getValue("long"));
      assertEquals(new Float(0.625f), contact.getValue("float"));
      assertEquals(new Double(1.625), contact.getValue("double"));
      assertEquals(new BigDecimal("1.2345"), contact.getValue("decimal"));
      assertEquals(new Timestamp(12345), contact.getValue("timestamp"));
      assertEquals(Boolean.TRUE, contact.getValue("boolean"));
      assertEquals(new Binary(new byte[]{1, 2, 3, 4, 5}), contact.getValue("binary"));
      assertEquals(new Binary(new byte[]{1, 2, 3, 4, 5, 6, 7}), contact.getValue("binary2"));
      assertEquals(new Binary(new byte[]{1, 2}), contact.getValue("binary3"));
      assertEquals("sym", ((Symbol)contact.getValue("symbol")).getName());
      assertSame(Symbol.define("sym"), contact.getValue("symbol"));
     
      Pair pairA = (Pair)contact.getValue("pair");
      assertEquals("A", pairA.getHead());
     
      Pair pairB = pairA.getNext();
      assertEquals("B", pairB.getHead());
      assertNull(pairB.getTail());

      char[] cvec = (char[])contact.getValue("cvector");

      assertEquals(3, cvec.length);
      assertEquals('a', cvec[0]);
      assertEquals('b', cvec[1]);
      assertEquals('c', cvec[2]);

      byte[] bvec = (byte[])contact.getValue("bvector");

      assertEquals(3, bvec.length);
      assertEquals(0, bvec[0]);
      assertEquals((byte)0xAB, bvec[1]);
      assertEquals(0x12, bvec[2]);

      String[] svec = (String[])contact.getValue("svector");

      assertEquals(3, svec.length);
      assertEquals("a", svec[0]);
      assertEquals("b", svec[1]);
      assertEquals("c", svec[2]);

      // XMLMarshaller is hardcoded to marshal Object[] as List for compatibility with MS.NET
      List vec = (List)contact.getValue("vector");

      assertEquals(3, vec.size());
      assertEquals("a", vec.get(0));
      assertEquals("b", vec.get(1));
      assertEquals("c", vec.get(2));

      PCodeFunction fun = (PCodeFunction)contact.getValue("function");

      assertEquals(3, fun.code.length);
      assertEquals(0, fun.code[0]);
      assertEquals(1, fun.code[1]);
      assertEquals(2, fun.code[2]);
      assertEquals(1, fun.constants.length);
      assertEquals("abc", fun.constants[0]);
     
      PCodeMacro mac = (PCodeMacro)contact.getValue("macro");
     
      assertEquals(3, mac.code.length);
      assertEquals(3, mac.code[0]);
      assertEquals(4, mac.code[1]);
      assertEquals(5, mac.code[2]);
      assertEquals(1, mac.constants.length);
      assertEquals("cde", mac.constants[0]);

      PrivilegeSet privilegeSet = (PrivilegeSet)contact.getValue("privilegeSet");

      assertTrue(privilegeSet.contains(Repository
                                          .getMetadata()
                                             .getPrimitivePrivilege("updateContact")));
      assertTrue(privilegeSet.contains(Repository
                                          .getMetadata()
                                             .getPrimitivePrivilege("WorkflowManage")));
      assertFalse(privilegeSet.contains(Repository
                                           .getMetadata()
                                              .getPrimitivePrivilege("createContact")));

      List addressList = (List)contact.getValue("addresses");

      assertEquals(2, addressList.size());

      TransferObject addr1 = (TransferObject)addressList.get(0);

      oid = addr1.getOID();

      assertEquals(1, oid.getCount());
      assertEquals("456", oid.getValue(0));

      assertEquals("Address-test", addr1.getClassName());
      assertEquals("update", addr1.getEventName());
      assertEquals(0, addr1.getVersion());
      assertEquals("Canada", addr1.getValue("country"));
      assertSame(addr1, addr1.getValue("self"));
      assertSame(contact, addr1.getValue("contact"));
      assertSame(contact.getValue("symbol"), addr1.getValue("symbol"));

      TransferObject addr2 = (TransferObject)addressList.get(1);

      assertEquals(2, addr2.getValueCount());
      assertEquals("USA", addr2.getValue("country"));
      assertSame(contact, addr2.getValue("contact"));
     
      // remove all pointer references,
      // objects are going to be different due to being unmarshalled from different branches of the
      // XML tree (i.e. correlator and first argument blocks)
      assertEqualsPointerless(req.getCorrelator(), addr2);
   }
View Full Code Here

TOP

Related Classes of nexj.core.rpc.Request$Invocation

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.