public virtual void testGetMessageElement() { JDFDoc d = new JDFDoc("JMF"); JDFJMF jmf = d.getJMFRoot(); JDFCommand c = (JDFCommand)jmf.appendMessageElement(EnumFamily.Command, EnumType.Events); Assert.AreEqual(c, jmf.getMessageElement(EnumFamily.Command, EnumType.Events, 0)); jmf.appendComment(); JDFSignal s = (JDFSignal)jmf.appendMessageElement(EnumFamily.Signal, EnumType.Events); Assert.AreEqual(s, jmf.getMessageElement(EnumFamily.Signal, EnumType.Events, 0)); Assert.AreEqual(s, jmf.getMessageElement(null, EnumType.Events, 1)); Assert.AreEqual(s, jmf.getMessageElement(null, null, 1)); JDFSignal s2 = (JDFSignal)jmf.appendMessageElement(EnumFamily.Signal, EnumType.Status); Assert.AreEqual(s2, jmf.getMessageElement(EnumFamily.Signal, EnumType.Status, 0)); Assert.AreEqual(s2, jmf.getMessageElement(EnumFamily.Signal, null, 1)); Assert.AreEqual(s2, jmf.getMessageElement(null, null, 2)); Assert.AreEqual(s2, jmf.getMessageElement(null, null, -1)); Assert.AreEqual(s, jmf.getMessageElement(null, null, -2)); Assert.AreEqual(c, jmf.getMessageElement(null, null, -3)); Assert.IsNull(jmf.getMessageElement(null, null, -4)); }
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")); }
public virtual void testMediaRef() { JDFDoc doc = new JDFDoc(ElementName.JMF); JDFJMF jmf = doc.getJMFRoot(); JDFSignal s = jmf.appendSignal(); jmf.setSenderID("DeviceSenderID"); s.setType(EnumType.Resource); JDFResourceQuParams rqp = s.appendResourceQuParams(); rqp.setJobID("JobID"); rqp.setJobPartID("JobPartID"); rqp.setResourceName(ElementName.EXPOSEDMEDIA); JDFResourceInfo ri = s.appendResourceInfo(); JDFExposedMedia xm = (JDFExposedMedia)ri.appendElement("ExposedMedia"); JDFResourceInfo ri2 = s.appendResourceInfo(); JDFMedia m = (JDFMedia)ri2.appendElement("Media"); JDFRefElement rm = xm.refElement(m); Assert.AreEqual(m, rm.getTarget(), "works initially "); Assert.AreEqual(m, rm.getTarget(), "also works with cache"); }
public virtual void testUsageCounter() { JDFDoc doc = new JDFDoc(ElementName.JMF); JDFJMF jmf = doc.getJMFRoot(); JDFSignal s = jmf.appendSignal(); jmf.setSenderID("DeviceSenderID"); s.setType(EnumType.Resource); JDFResourceQuParams rqp = s.appendResourceQuParams(); rqp.setJobID("JobID"); rqp.setJobPartID("JobPartID"); rqp.setResourceName(ElementName.USAGECOUNTER); JDFResourceInfo ri = s.appendResourceInfo(); ri.setActualAmount(42); JDFUsageCounter uc = (JDFUsageCounter)ri.appendElement(ElementName.USAGECOUNTER); uc.setID("UsageCounterID"); uc.setScope(EnumScope.Job); uc.setCounterID("DeviceCounterID"); uc.setResStatus(EnumResStatus.Available, true); uc.setCounterTypes(new VString("NormalSize", " ")); doc.write2File(sm_dirTestDataTemp + "JMFResourceSignal.jmf", 2, false); Assert.IsTrue(jmf.isValid(EnumValidationLevel.Complete)); }
public virtual void testAppendValidElement() { JDFDoc doc = new JDFDoc(ElementName.JMF); JDFJMF jmf = doc.getJMFRoot(); JDFSignal sig = (JDFSignal)jmf.appendMessageElement(EnumFamily.Signal,EnumType.UpdateJDF); Assert.IsNotNull(sig.appendValidElement(ElementName.UPDATEJDFCMDPARAMS,null)); }
public virtual void testGetInvalidAttributes() { JDFDoc doc = new JDFDoc(ElementName.JMF); JDFJMF jmf = doc.getJMFRoot(); JDFSignal sig = (JDFSignal)jmf.appendMessageElement(EnumFamily.Signal,EnumType.UpdateJDF); Assert.IsNotNull(sig.appendValidElement(ElementName.UPDATEJDFCMDPARAMS,null)); Assert.IsFalse(sig.getInvalidAttributes(EnumValidationLevel.Complete,true,999).Contains(AttributeName.XSITYPE)); sig.setAttribute("Type",EnumType.AbortQueueEntry.getName()); Assert.IsTrue(sig.getInvalidAttributes(EnumValidationLevel.Complete,true,999).Contains(AttributeName.XSITYPE)); }
public virtual void testPrivateMessage() { JDFDoc doc = new JDFDoc(ElementName.JMF); JDFJMF jmf = doc.getJMFRoot(); JDFSignal s = (JDFSignal)jmf.appendMessageElement(EnumFamily.Signal, null); s.setType("foo:test"); s.appendDevice(); Assert.IsNull(s.getXSIType()); Assert.IsTrue(s.getDevice(0) != null, "get device"); }
public override void setUp() { base.setUp(); JDFElement.setLongID(false); doc = new JDFDoc(ElementName.JMF); jmf = doc.getJMFRoot(); signal = jmf.appendSignal(); jmf.setSenderID("DeviceSenderID"); signal.setType(EnumType.Status); sqp = signal.appendStatusQuParams(); sqp.setJobID("JobID"); sqp.setJobPartID("JobPartID"); }
public virtual void testGetMessageVector() { JDFDoc doc = new JDFDoc(ElementName.JMF); JDFJMF jmf = doc.getJMFRoot(); JDFCommand command = (JDFCommand)jmf.appendMessageElement(EnumFamily.Command, EnumType.Status); Assert.AreEqual(command, jmf.getMessageVector(null, EnumType.Status)[0]); Assert.AreEqual(1, jmf.getMessageVector(null, EnumType.Status).Count); JDFSignal signal = (JDFSignal)jmf.appendMessageElement(EnumFamily.Signal, EnumType.Status); Assert.AreEqual(command, jmf.getMessageVector(null, EnumType.Status)[0]); Assert.AreEqual(signal, jmf.getMessageVector(null, EnumType.Status)[1]); Assert.AreEqual(2, jmf.getMessageVector(null, EnumType.Status).Count); }
/// /// <summary> * convert all responses that match the query q to signals /// * </summary> /// * <returns> the newly created JMF with multiple responses </returns> /// public virtual void convertResponses(JDFQuery q) { EnumType t = q == null ? null : q.getEnumType(); VElement v = getMessageVector(EnumFamily.Response, t); string qID = q == null ? null : q.getID(); for (int i = 0; i < v.Count; i++) { JDFResponse r = (JDFResponse)v[i]; if (qID == null || qID.Equals(r.getrefID())) { JDFSignal s = appendSignal(); moveElement(s, r); // retain ordering s.convertResponse(r, q); r.deleteNode(); } } }
public virtual void testIsValidMessageElement() { JDFDoc doc = new JDFDoc(ElementName.JMF); JDFJMF jmf = doc.getJMFRoot(); JDFSignal sig = (JDFSignal)jmf.appendMessageElement(EnumFamily.Signal, EnumType.UpdateJDF); Assert.IsTrue(sig.isValidMessageElement(ElementName.UPDATEJDFCMDPARAMS, 0)); Assert.IsFalse(sig.isValidMessageElement(ElementName.MODIFYNODECMDPARAMS, 0)); JDFResponse resp = (JDFResponse)jmf.appendMessageElement(EnumFamily.Response, EnumType.RepeatMessages); Assert.IsTrue(resp.isValidMessageElement(ElementName.SIGNAL,3)); Assert.IsTrue(resp.isValidMessageElement(ElementName.REGISTRATION,3)); Assert.IsFalse(resp.isValidMessageElement(ElementName.QUEUE,0)); JDFRegistration reg = (JDFRegistration)jmf.appendMessageElement(EnumFamily.Registration,EnumType.RepeatMessages); Assert.IsFalse(reg.isValidMessageElement(ElementName.SIGNAL,3)); }
public virtual void testJobPhase() { JDFDoc doc = new JDFDoc(ElementName.JMF); JDFJMF jmf = doc.getJMFRoot(); JDFSignal s = (JDFSignal)jmf.appendMessageElement(EnumFamily.Signal, null); s.setType("Status"); JDFStatusQuParams sqp = s.appendStatusQuParams(); sqp.setDeviceDetails(EnumDeviceDetails.Brief); JDFDeviceInfo di = s.appendDeviceInfo(); JDFJobPhase jp = di.appendJobPhase(); Assert.AreEqual(di.getJobPhase(0), jp); jp = (JDFJobPhase)di.appendElement("jdf:JobPhase", JDFElement.getSchemaURL()); Assert.AreEqual(di.getJobPhase(1), jp); Assert.IsNull(di.getJobPhase(2)); jp.appendNode(); Assert.IsTrue(jp.isValid(EnumValidationLevel.Incomplete)); }
public virtual void testMedia() { JDFDoc doc = new JDFDoc(ElementName.JMF); JDFJMF jmf = doc.getJMFRoot(); JDFSignal s = jmf.appendSignal(); jmf.setSenderID("DeviceSenderID"); s.setType(EnumType.Resource); JDFResourceQuParams rqp = s.appendResourceQuParams(); rqp.setJobID("JobID"); rqp.setJobPartID("JobPartID"); rqp.setResourceName(ElementName.MEDIA); JDFResourceInfo ri = s.appendResourceInfo(); ri.getCreateAmountPool(); // TODO continue }
public virtual void testModifyNode() { JDFDoc doc = new JDFDoc(ElementName.JMF); JDFJMF jmf = doc.getJMFRoot(); JDFSignal sig = (JDFSignal)jmf.appendMessageElement(EnumFamily.Signal,EnumType.ModifyNode); JDFModifyNodeCmdParams mnp = sig.appendModifyNodeCmdParams(); Assert.IsNotNull(mnp); JDFModifyNodeCmdParams mnp2 = sig.getModifyNodeCmdParams(); Assert.AreEqual(mnp,mnp2); mnp2 = sig.getCreateModifyNodeCmdParams(); Assert.AreEqual(mnp,mnp2); try { sig.appendModifyNodeCmdParams(); Assert.Fail("oops"); } catch (JDFException) { // nop } }