Ejemplo n.º 1
0
        public virtual void testEraseEmptyNodes()
        {
            JDFDoc     doc  = new JDFDoc(ElementName.JDF);
            JDFNode    root = doc.getJDFRoot();
            JDFComment c11  = root.appendComment();
            string     txt  = "      \n\n";

            c11.setText(txt);
            root.eraseEmptyNodes(true);
            Assert.AreEqual(txt, c11.getText(), "whitespace is not removed");
        }
Ejemplo n.º 2
0
        public virtual void testDirtyIDs()
        {
            // -i bookintent.jdf -o spawned.jdf -p 4
            string xmlFile   = "bookintent.jdf";
            string outFile   = "spawned.jdf";
            string strPartID = "4";

            JDFParser p        = new JDFParser();
            JDFDoc    jdfDocIn = p.parseFile(sm_dirTestData + xmlFile);

            Assert.IsTrue(jdfDocIn != null);
            if (jdfDocIn == null)
            {
                return; // soothe findbugs ;)
            }

            XMLDocUserData xmlUserData = jdfDocIn.getCreateXMLDocUserData();

            xmlUserData.setDirtyPolicy(XMLDocUserData.EnumDirtyPolicy.ID);

            JDFNode rootIn = (JDFNode)jdfDocIn.getRoot();

            JDFNode nodeToSpawn;

            if (strPartID.Equals(""))
            {
                nodeToSpawn = rootIn;
            }
            else
            {
                nodeToSpawn = rootIn.getJobPart(strPartID, "");
            }

            if (nodeToSpawn == null)
            {
                Assert.Fail("No such JobPartID: " + strPartID);
            }
            else
            {
                ArrayList vRWResources = new ArrayList();
                vRWResources.Add("Component");
                vRWResources.Add("RunList");

                VJDFAttributeMap vSpawnParts = new VJDFAttributeMap();
                JDFSpawn         spawn       = new JDFSpawn(nodeToSpawn);

                JDFNode node = spawn.spawn(xmlFile, outFile, vRWResources, vSpawnParts, false, false, false, false);

                // neu gespawntes FileInfo rausschreiben
                JDFNode rootOut = node;
                XMLDoc  docOut  = rootOut.getOwnerDocument_KElement();
                docOut.write2File(sm_dirTestDataTemp + outFile, 0, true);

                // verändertes Ausgangsfile rausschreiben
                string strOutXMLFile = "_" + xmlFile;
                rootIn.eraseEmptyNodes(true);
                jdfDocIn.write2File(sm_dirTestDataTemp + strOutXMLFile, 0, true);
                Assert.IsTrue(true, "SpawnJDF ok");

                // test, if all changed nodes are in our list

                // Java to C# Conversion - Java version indicated there should be 5 Dirty IDs, but it only checks for 4.
                //                         C# version returns 4 Dirty IDs.  Set it to 4 for now.
                VString vstrDirtyIDs = jdfDocIn.getDirtyIDs();
                Assert.AreEqual(4, vstrDirtyIDs.Count);
                Assert.IsTrue(vstrDirtyIDs.Contains("n0014")); // audit pool was added
                Assert.IsTrue(vstrDirtyIDs.Contains("n0016")); // status changed:
                // waiting --> spawned
                Assert.IsTrue(vstrDirtyIDs.Contains("r0017")); //SpawnStatus="SpawnedRW"
                // added
                Assert.IsTrue(vstrDirtyIDs.Contains("r0018")); // SizeIntent added
            }
        }