Exemplo n.º 1
0
        public virtual void testConvertResponse()
        {
            JDFDoc      doc  = new JDFDoc(ElementName.JMF);
            JDFJMF      jmf  = doc.getJMFRoot();
            JDFDoc      doc2 = new JDFDoc(ElementName.JMF);
            JDFJMF      jmf2 = doc2.getJMFRoot();
            JDFSignal   s    = jmf.appendSignal();
            JDFResponse r    = jmf2.appendResponse();
            JDFQuery    q    = jmf.appendQuery();

            q.setType("KnownMessages");
            r.setQuery(q);
            Assert.AreEqual(q.getID(), r.getrefID(), "refID");

            JDFMessageService ms = r.appendMessageService();

            ms.setType("KnownMessages");
            s.convertResponse(r, q);
            Assert.AreEqual(r.getType(), s.getType(), "type");
            Assert.IsTrue(ms.isEqual(s.getMessageService(0)), "ms equal");
            s = jmf.appendSignal();
            s.convertResponse(r, null);
            Assert.AreEqual(r.getType(), s.getType(), "type");
            Assert.IsTrue(ms.isEqual(s.getMessageService(0)), "ms equal");
            Assert.IsTrue(s.getXSIType().StartsWith("Signal"));
        }
Exemplo n.º 2
0
        ///
        ///	 <summary> * converts a response to a signal that can be sent individually
        ///	 *  </summary>
        ///	 * <param name="response"> the response to convert </param>
        ///	 * <returns> true if successful </returns>
        ///
        public virtual bool convertResponse(JDFResponse response, JDFQuery q)
        {
            if (response == null)
            {
                return(false);
            }
            setAttributes(response);
            VElement elements = response.getChildElementVector(null, null, null, true, 0, true);

            for (int i = 0; i < elements.Count; i++)
            {
                JDFElement element = (JDFElement)elements[i];
                copyElement(element, null);
            }
            if (q != null)
            {
                VElement v = q.getChildElementVector(null, null, null, true, 0, true);
                for (int i = 0; i < v.Count; i++)
                {
                    KElement item = v.item(i);
                    if (item is JDFSubscription)
                    {
                        continue;
                    }
                    copyElement(item, null);
                }
            }
            setType(response.getType()); // also fix xsi:type
            return(true);
        }
Exemplo n.º 3
0
        public virtual void testCreateResponse()
        {
            JDFDoc     doc     = new JDFDoc(ElementName.JMF);
            JDFJMF     jmf     = doc.getJMFRoot();
            JDFCommand command = (JDFCommand)jmf.appendMessageElement(EnumFamily.Command,EnumType.UpdateJDF);

            Assert.AreEqual("CommandUpdateJDF",command.getXSIType());
            command.setType("foo:bar");
            Assert.IsNull(command.getXSIType());
            Assert.AreEqual("foo:bar",command.getType());
            JDFJMF      resp     = command.createResponse();
            JDFResponse response = resp.getResponse(0);

            Assert.AreEqual(resp.getMessageElement(null,null,0),response);
            Assert.AreEqual("foo:bar",response.getType());
            Assert.AreEqual(command.getID(),response.getrefID());
        }
Exemplo n.º 4
0
        public virtual void testCreateResponse()
        {
            JDFJMF queries = JDFJMF.createJMF(EnumFamily.Query, EnumType.Status);

            queries.appendCommand(EnumType.Resource);
            queries.appendCommand(EnumType.Resource);
            queries.appendRegistration(EnumType.Resource);

            JDFJMF   responses      = queries.createResponse();
            VElement messageVector  = queries.getMessageVector(null, null);
            VElement responseVector = responses.getMessageVector(null, null);

            Assert.AreEqual(responseVector.Count, 4);
            for (int i = 0; i < responseVector.Count; i++)
            {
                JDFResponse r = (JDFResponse)responseVector[i];
                JDFMessage  m = (JDFMessage)messageVector[i];
                Assert.AreEqual(r.getrefID(), m.getID());
                Assert.AreEqual(r.getType(), m.getType());
            }
        }