Example #1
0
        public virtual void testValidatePrivateDoc()
        {
            JDFDoc       doc      = new JDFDoc("JDF");
            JDFValidator checkJDF = new JDFValidator();

            checkJDF.setPrint(false);
            checkJDF.bQuiet = true;
            checkJDF.level  = EnumValidationLevel.Incomplete;
            JDFNode n = doc.getJDFRoot();

            checkJDF.setIgnorePrivate(true);

            n.setAttribute("foo:bar", "foobar", "www.foo.cpm");
            XMLDoc   schemaValidationResult = checkJDF.processSingleDocument(doc);
            KElement root = schemaValidationResult.getRoot();

            Assert.AreEqual(root.getXPathAttribute("TestFile/CheckJDFOutput/@IsValid", "booboo"), "true");

            n.removeAttribute("bar", "www.foo.cpm");
            n.appendElement("foo:bar", "www.foo.cpm");
            schemaValidationResult = checkJDF.processSingleDocument(doc);
            root = schemaValidationResult.getRoot();
            Assert.AreEqual(root.getXPathAttribute("TestFile[2]/CheckJDFOutput/@IsValid", "booboo"), "true");

            n.setAttribute("jdfbar", "thisbebad");
            schemaValidationResult = checkJDF.processSingleDocument(doc);
            root = schemaValidationResult.getRoot();
            Assert.AreEqual(root.getXPathAttribute("TestFile[3]/CheckJDFOutput/@IsValid", "booboo"), "false");

            n.removeAttribute("jdfbar", null);
            n.appendElement("jdfbar", null);
            schemaValidationResult = checkJDF.processSingleDocument(doc);
            root = schemaValidationResult.getRoot();
            Assert.AreEqual(root.getXPathAttribute("TestFile[4]/CheckJDFOutput/@IsValid", "booboo"), "false");
        }
Example #2
0
        public virtual void testValidateCombined()
        {
            JDFDoc       doc      = new JDFDoc("JDF");
            JDFValidator checkJDF = new JDFValidator();

            checkJDF.setPrint(false);
            checkJDF.bQuiet = true;
            JDFNode n = doc.getJDFRoot();

            n.setType(EnumType.Combined);
            int v = 0;

            while (true)
            {
                checkJDF.level = EnumValidationLevel.getEnum(v);
                if (checkJDF.level == null)
                {
                    break;
                }
                for (int i = 0; i < 3; i++)
                {
                    if (i >= 1)
                    {
                        doc = null;
                    }
                    XMLDoc   schemaValidationResult = checkJDF.processSingleDocument(doc);
                    KElement root = schemaValidationResult.getRoot();
                    Assert.IsNotNull(root.getXPathElement("TestFile/SchemaValidationOutput"));
                    Assert.IsNotNull(root.getXPathElement("TestFile/CheckJDFOutput"));
                    Assert.AreEqual(root.getXPathAttribute("TestFile/CheckJDFOutput/@IsValid", "booboo"), "true");
                }
                v++;
            }
        }
Example #3
0
        public virtual void testPrivateValidate()
        {
            StatusCounter sc = new StatusCounter(null, null, null);

            sc.setEvent("id1", "good", "blah");
            JDFValidator c = new JDFValidator();

            c.setValidatorFactory(new ValidFactory());
            JDFDoc d = sc.getDocJMFNotification(true);

            Assert.IsTrue(c.isValid(d));
            sc.setEvent("id2", "oops", "Snafu");
            d = sc.getDocJMFNotification(true);
            // XMLDoc report=
            c.processSingleDocument(d);
            Assert.IsFalse(c.isValid(d));
        }
Example #4
0
        private void processSingleFile(string fileName, bool bShouldValidate, EnumValidationLevel level)
        {
            JDFValidator checkJDF = new JDFValidator();

            checkJDF.setPrint(false);
            checkJDF.bQuiet = true;
            checkJDF.level  = level != null ? level : EnumValidationLevel.Complete;
            XMLDoc   schemaValidationResult = checkJDF.processSingleFile(fileName);
            KElement root = schemaValidationResult.getRoot();

            Assert.IsNotNull(root.getXPathElement("TestFile/SchemaValidationOutput"));
            Assert.IsNotNull(root.getXPathElement("TestFile/CheckJDFOutput"));

            checkJDF = new JDFValidator();
            checkJDF.setPrint(false);
            checkJDF.bQuiet = true;
            checkJDF.level  = EnumValidationLevel.Complete;
            checkJDF.processSingleFile(fileName);
            Assert.IsNotNull(root);

            if (bShouldValidate)
            {
                Assert.AreEqual(root.getXPathAttribute("TestFile/CheckJDFOutput/@IsValid", ""), "true", fileName + " should validate");
            }
            else
            {
                Assert.AreEqual(root.getXPathAttribute("TestFile/CheckJDFOutput/@IsValid", ""), "false", fileName + " should not validate");
            }

            // now repeat including schema
            checkJDF.setJDFSchemaLocation(new FileInfo(sm_dirTestSchema + "JDF.xsd"));
            checkJDF.processSingleDocument(null);
            Assert.IsNotNull(root);

            if (bShouldValidate)
            {
                Assert.AreEqual(root.getXPathAttribute("TestFile/CheckJDFOutput/@IsValid", ""), "true");
            }
            else
            {
                Assert.AreEqual(root.getXPathAttribute("TestFile/CheckJDFOutput/@IsValid", ""), "false");
            }
        }
Example #5
0
        public virtual void testBadResLink()
        {
            JDFDoc  d = new JDFDoc("JDF");
            JDFNode n = d.getJDFRoot();

            n.setType(EnumType.Stitching);
            JDFResource     r  = n.addResource(ElementName.STITCHINGPARAMS, EnumUsage.Input);
            JDFResourceLink rl = n.getLink(r, null);

            Assert.IsTrue(rl.isValid(EnumValidationLevel.Complete));
            Assert.IsTrue(n.isValid(EnumValidationLevel.Incomplete));
            rl.setrRef("badLink");
            Assert.IsFalse(rl.isValid(EnumValidationLevel.Complete));
            Assert.IsFalse(n.isValid(EnumValidationLevel.Complete));
            JDFValidator cj   = new JDFValidator();
            XMLDoc       res  = cj.processSingleDocument(d);
            KElement     root = res.getRoot();
            string       s    = root.ToString();

            Assert.IsTrue(s.IndexOf("Dangling") > 0);
        }