public virtual void testMergeLastPhase() { JDFDoc d = new JDFDoc("JDF"); JDFAuditPool ap = d.getJDFRoot().getCreateAuditPool(); JDFPhaseTime pt = ap.setPhase(EnumNodeStatus.InProgress, "dummy", null, null); JDFJobPhase jp = di.createJobPhaseFromPhaseTime(pt); jp.setPhaseAmount(200); jp.setAmount(200); jp.setPhaseWaste(100); JDFDate d1 = jp.getPhaseStartTime(); JDFDoc doc = new JDFDoc(ElementName.DEVICEINFO); JDFDeviceInfo di2 = (JDFDeviceInfo)doc.getRoot(); JDFJobPhase jp2 = (JDFJobPhase)di2.copyElement(jp, null); jp2.setPhaseStartTime(new JDFDate()); StatusCounter.sleep(1000); jp2.setPhaseAmount(300); jp2.setPhaseWaste(30); jp2.setAmount(500); Assert.IsTrue(di2.mergeLastPhase(di)); Assert.AreEqual(d1, jp2.getPhaseStartTime()); Assert.AreEqual(130.0, jp2.getPhaseWaste(), 0.0); Assert.AreEqual(500.0, jp2.getPhaseAmount(), 0.0); Assert.AreEqual(500.0, jp2.getAmount(), 0.0); }
public virtual void testThreads() { q.setAutomated(true); q.removeChildren(ElementName.QUEUEENTRY, null, null); q.setMaxCompletedEntries(999999999); for (int i = 0; i < 10; i++) { QueueTestThread queueTestThread = new QueueTestThread(); Thread runThread = new Thread(new ThreadStart(queueTestThread.Run)); runThread.Name = "Test Thread_" + i; runThread.Start(); } // now also zapp some... for (int j = 0; j < 100; j++) { JDFQueueEntry qex = q.getNextExecutableQueueEntry(); if (qex != null) { qex.setQueueEntryStatus(EnumQueueEntryStatus.Running); qex.setQueueEntryStatus(EnumQueueEntryStatus.Completed); } } while (iThread > 0) { StatusCounter.sleep(100); // wait for threads to be over } Assert.AreEqual(q.getQueueSize(), 1000); VElement v = q.getQueueEntryVector(); JDFQueueEntry qeLast = null; for (int i = 0; i < v.Count; i++) { JDFQueueEntry qe = (JDFQueueEntry)v[i]; Console.WriteLine(qe.getPriority() + " " + qe.getQueueEntryID() + " " + qe.getQueueEntryStatus()); Assert.IsTrue(qe.CompareTo(qeLast) >= 0); qeLast = qe; } v = q.getQueueEntryVector(new JDFAttributeMap(AttributeName.STATUS, "Completed"), null); Assert.AreEqual(100, v.Count); v = q.getQueueEntryVector(new JDFAttributeMap(AttributeName.STATUS, "Running"), null); Assert.IsNull(v); v = q.getQueueEntryVector(new JDFAttributeMap(AttributeName.STATUS, "Held"), null); Assert.AreEqual(500, v.Count); v = q.getQueueEntryVector(new JDFAttributeMap(AttributeName.STATUS, "Waiting"), null); Assert.AreEqual(400, v.Count); }