Example #1
0
        public virtual void testFitsContext()
        {
            JDFDoc  d = new JDFDoc(ElementName.TEST);
            JDFTest t = (JDFTest)d.getRoot();

            t.init();
            t.setContext("//JDF");
            JDFDoc  jdf  = new JDFDoc(ElementName.JDF);
            JDFNode node = jdf.getJDFRoot();

            node.setType(EnumType.ProcessGroup);
            JDFNode     node2 = node.addJDFNode("foobar");
            JDFResource r2    = node.addResource("res", EnumResourceClass.Parameter, EnumUsage.Input, null, null, null, null);

            Assert.IsTrue(t.fitsContext(node));
            Assert.IsTrue(t.fitsContext(node2));
            t.setContext("JDF");
            Assert.IsTrue(t.fitsContext(node));
            Assert.IsTrue(t.fitsContext(node2));
            t.setContext("/JDF");
            Assert.IsTrue(t.fitsContext(node));
            Assert.IsFalse(t.fitsContext(node2));
            t.setContext("res");
            Assert.IsTrue(t.fitsContext(r2));
            t.setContext("/res");
            Assert.IsFalse(t.fitsContext(r2));
        }
Example #2
0
        public virtual void testIsPresentPartition()
        {
            JDFAction act = devicecap.appendActionPool().appendActionTest(EnumTerm.IsPresentEvaluation, true);
            JDFTest   tst = act.getTest();

            tst.setContext("//Component");
            JDFIsPresentEvaluation ipe = (JDFIsPresentEvaluation)tst.getTerm();

            ipe.setRefTarget(ptState);
            Assert.AreEqual(ptState.getID(), ipe.getrRef());

            JDFDoc  doc  = new JDFDoc("JDF");
            JDFNode node = doc.getJDFRoot();

            node.setType("fnarf", false);
            JDFComponent comp = (JDFComponent)node.addResource("Component", null, EnumUsage.Input, null, null, null, null);

            comp.setProductType("Cover");

            XMLDoc   rep     = new XMLDoc("root", null);
            KElement eRep    = rep.getRoot();
            bool     fitsJDF = tst.fitsJDF(comp, eRep);

            Assert.IsTrue(fitsJDF);
            comp    = (JDFComponent)comp.addPartition(EnumPartIDKey.SheetName, "s1");
            fitsJDF = tst.fitsJDF(comp, eRep);
            Assert.IsTrue(fitsJDF, "also partition leaves ");
        }
Example #3
0
        public virtual void testValidTest1()
        {
            JDFDoc  d = new JDFDoc(ElementName.TEST);
            JDFTest t = (JDFTest)d.getRoot();

            t.init();
            t.appendTerm(EnumTerm.IsPresentEvaluation);
            Assert.IsTrue(t.isValid(EnumValidationLevel.Complete));
            t.appendTerm(EnumTerm.BooleanEvaluation); // no two are allowed
            Assert.IsFalse(t.isValid(EnumValidationLevel.Complete));
        }
Example #4
0
        public virtual void testAction()
        {
            JDFDoc        d    = new JDFDoc(ElementName.DEVICECAP);
            JDFDeviceCap  dc   = (JDFDeviceCap)d.getRoot();
            JDFTestPool   tp   = dc.appendTestPool();
            JDFTest       test = tp.appendTest();
            JDFActionPool ap   = dc.appendActionPool();
            JDFAction     a    = ap.appendAction();

            a.setTest(test);
            Assert.AreEqual(test, a.getTest());
            Assert.IsTrue(a.hasAttribute("TestRef"));
        }
Example #5
0
        public virtual void testAction()
        {
            JDFAction act = devicecap.appendActionPool().appendActionTest(EnumTerm.or, false);
            JDFTest   tst = act.getTest();

            tst.setContext("/JDF/ResourcePool/Component");
            JDFor or = (JDFor)((JDFnot)tst.getTerm()).getTerm(EnumTerm.or, 0);
            JDFIsPresentEvaluation ipe = (JDFIsPresentEvaluation)or.appendTerm(EnumTerm.IsPresentEvaluation);

            ipe.setRefTarget(ptState);
            Assert.AreEqual(ptState.getID(), ipe.getrRef());

            JDFEnumerationEvaluation enev = (JDFEnumerationEvaluation)or.appendTerm(EnumTerm.EnumerationEvaluation);

            enev.setRefTarget(compState);
            enev.setRegExp("(.+ )*FinalProduct( .+)*");

            JDFDoc  doc  = new JDFDoc("JDF");
            JDFNode node = doc.getJDFRoot();

            node.setType("fnarf", false);
            JDFComponent comp = (JDFComponent)node.addResource("Component", null, EnumUsage.Input, null, null, null, null);

            XMLDoc   rep     = new XMLDoc("root", null);
            KElement eRep    = rep.getRoot();
            bool     fitsJDF = tst.fitsJDF(comp, eRep);

            Assert.IsTrue(fitsJDF);

            comp.setProductType("foobar");
            fitsJDF = tst.fitsJDF(comp, eRep);
            Assert.IsFalse(fitsJDF, "have pt");

            List <ValuedEnum> v = new List <ValuedEnum>();

            v.Add(EnumComponentType.FinalProduct);
            comp.setComponentType(v);
            fitsJDF = tst.fitsJDF(comp, eRep);
            Assert.IsFalse(fitsJDF, "have both");

            comp.removeAttribute("ProductType");
            fitsJDF = tst.fitsJDF(comp, eRep);
            Assert.IsFalse(fitsJDF, "have final");

            v = new List <ValuedEnum>();
            v.Add(EnumComponentType.PartialProduct);
            comp.setComponentType(v);
            fitsJDF = tst.fitsJDF(comp, eRep);
            Assert.IsTrue(fitsJDF, "have no final");
        }
Example #6
0
        ///
        ///     <summary> * Get all Test from the current element
        ///     *  </summary>
        ///     * <returns> Collection<JDFTest> </returns>
        ///
        public virtual ICollection <JDFTest> getAllTest()
        {
            List <JDFTest> v = new List <JDFTest>();

            JDFTest kElem = (JDFTest)getFirstChildElement(ElementName.TEST, null);

            while (kElem != null)
            {
                v.Add(kElem);

                kElem = (JDFTest)kElem.getNextSiblingElement(ElementName.TEST, null);
            }

            return(v);
        }
Example #7
0
        public virtual void testLogic()
        {
            JDFDoc       d  = new JDFDoc(ElementName.DEVICECAP);
            JDFDeviceCap dc = (JDFDeviceCap)d.getRoot();

            dc.appendDevCapPool();

            JDFTestPool tp   = dc.appendTestPool();
            JDFTest     test = tp.appendTest();

            test.appendTerm(EnumTerm.and);
            JDFActionPool ap = dc.appendActionPool();
            JDFAction     a  = ap.appendAction();

            a.setTest(test);
            // TODO more
        }
Example #8
0
        public virtual void testAppendActionTest()
        {
            JDFDoc        d    = new JDFDoc(ElementName.PREFLIGHTPARAMS);
            JDFActionPool ap   = (JDFActionPool)d.getRoot().appendElement(ElementName.ACTIONPOOL);
            JDFAction     a    = ap.appendActionTest(EnumTerm.and, true);
            JDFTest       test = a.getTest();

            Assert.IsNotNull(test);
            Assert.IsNotNull(test.getTerm());
            Assert.IsTrue(test.getTerm() is JDFand);

            a    = ap.appendActionTest(EnumTerm.and, false);
            test = a.getTest();
            Assert.IsNotNull(test);
            Assert.IsNotNull(test.getTerm());
            Assert.IsTrue(test.getTerm() is JDFnot);
            Assert.IsTrue(((JDFnot)test.getTerm()).getTerm(null, 0) is JDFand);
        }
Example #9
0
        public void testFitsTolerance()
        {
            try
            {
                new JDFXYPairRangeList("0.4 1.9~1.4 2.9 0.4 1.9~2.4 3.8 0.4 1.6");

                JDFDoc  d = new JDFDoc(ElementName.TEST);
                JDFTest t = (JDFTest)d.getRoot();
                t.init();
                JDFXYPairEvaluation xyPairEvaluation = (JDFXYPairEvaluation)t.appendTerm(EnumTerm.XYPairEvaluation);
                xyPairEvaluation.setTolerance(new JDFXYPair("0 0"));
                Assert.IsTrue(t.isValid(EnumValidationLevel.Complete));

                Assert.AreEqual(new JDFXYPair("0 0"), xyPairEvaluation.getTolerance());
                xyPairEvaluation.setTolerance(new JDFXYPair("0.1 0.1"));
            }
            catch (FormatException dfe)
            {
                Assert.Fail(dfe.ToString());
            }
        }
Example #10
0
        public virtual void testAppendExcludeTest()
        {
            JDFDoc       d  = new JDFDoc(ElementName.DEVICECAP);
            JDFDeviceCap dc = (JDFDeviceCap)d.getRoot();

            JDFActionPool   ap   = (JDFActionPool)d.getRoot().appendElement(ElementName.ACTIONPOOL);
            JDFDevCaps      dcs  = dc.appendDevCaps();
            JDFStringState  stst = dcs.appendDevCap().appendStringState("stbar");
            JDFIntegerState ist  = dcs.appendDevCap().appendIntegerState("ibar");

            JDFAction ac = ap.appendExcludeTest(stst, ist);

            Assert.IsNotNull(ac);
            JDFTest t = ac.getTest();

            Assert.IsNotNull(t);
            JDFand a = (JDFand)t.getTerm();

            Assert.IsNotNull(a);
            Assert.IsNotNull(a.getTerm(EnumTerm.StringEvaluation, 0));
            Assert.IsNotNull(a.getTerm(EnumTerm.IntegerEvaluation, 0));
        }
Example #11
0
        public virtual void testJMFDevCaps()
        {
            JDFDoc doc   = new JDFDoc(ElementName.JMF);
            JDFJMF jmfDC = doc.getJMFRoot();

            JDFResponse r = jmfDC.appendResponse(EnumType.KnownMessages);

            jmfDC.setSenderID("DeviceSenderID");

            JDFMessageService ms = r.appendMessageService();

            ms.setJMFRole(EnumJMFRole.Sender);
            ms.setQuery(true);
            ms.setType("KnownDevices");
            JDFDevCaps dcs = ms.appendDevCaps();

            dcs.setName("DeviceList");
            JDFDevCap dc   = dcs.appendDevCapInPool();
            JDFDevCap dcDI = dc.appendDevCap();

            dcDI.setName(ElementName.DEVICEINFO);
            dcDI.setMinOccurs(1);
            dcDI.setMaxOccurs(1);
            JDFStringState state = dcDI.appendStringState(AttributeName.DEVICEID);

            state.setRequired(true);

            state = dcDI.appendStringState(AttributeName.DEVICESTATUS);
            state.setRequired(true);
            state.appendValueAllowedValue("Running");

            ms = r.appendMessageService();
            ms.setJMFRole(EnumJMFRole.Sender);
            ms.setQuery(true);
            ms.setType("KnownMessages");
            dcs = ms.appendDevCaps();
            dcs.setName("MessageService");
            dc    = dcs.appendDevCapInPool();
            state = dc.appendStringState(AttributeName.TYPE);
            state.setRequired(true);
            state = dc.appendStringState("Foo");
            state.setRequired(false);

            JDFActionPool ap = ms.appendActionPool();
            JDFAction     a  = ap.appendActionTest(EnumTerm.IsPresentEvaluation, true);
            JDFTest       t  = a.getTest();

            // JDFTerm term=
            t.getTerm();
            // TODO
            JDFDoc docJMF = new JDFDoc("JMF");
            JDFJMF jmf    = docJMF.getJMFRoot();

            for (int i = 0; i < 3; i++)
            {
                JDFResponse   resp = jmf.appendResponse(EnumType.KnownDevices);
                JDFDeviceList dl   = resp.appendDeviceList();
                JDFDeviceInfo di   = dl.appendDeviceInfo();
                di.setDeviceID("d123");
                di.setDeviceStatus(EnumDeviceStatus.Running);
                XMLDoc report = JDFDeviceCap.getJMFInfo(jmf, r, EnumFitsValue.Allowed, EnumValidationLevel.Complete, true);
                Assert.AreEqual("true", report.getRoot().getAttribute("IsValid"));
            }
            {
                JDFResponse       resp = jmf.appendResponse(EnumType.KnownMessages);
                JDFMessageService mi   = resp.appendMessageService();
                mi.setType("FooBar");
                doc.write2File(sm_dirTestDataTemp + "JMFDevCap.xml", 2, false);
                docJMF.write2File(sm_dirTestDataTemp + "JMFDevCapTest.jmf", 2, false);
            }
            XMLDoc report_1 = JDFDeviceCap.getJMFInfo(jmf, r, EnumFitsValue.Allowed, EnumValidationLevel.Complete, true);

            Assert.AreEqual("true", report_1.getRoot().getAttribute("IsValid"));

            doc.write2File(sm_dirTestDataTemp + "JMFDevCap.xml", 2, false);
            docJMF.write2File(sm_dirTestDataTemp + "JMFDevCapTest.jmf", 2, false);
            {
                jmf.appendResponse(EnumType.AbortQueueEntry);
            }
            report_1 = JDFDeviceCap.getJMFInfo(jmf, r, EnumFitsValue.Allowed, EnumValidationLevel.Complete, true);
            Assert.AreEqual("false", report_1.getRoot().getAttribute("IsValid"));
        }