Example #1
0
        ///
        ///	 <summary> * getIndexFromVersion
        ///	 *  </summary>
        ///	 * <param name="v">
        ///	 * @return </param>
        ///
        private static int getIndexFromVersion(EnumVersion v)
        {
            int i = v.getValue();

            if (forceVersion || (i <= 0) || (i > jdfVersions.Length))
            {
                i = JDFElement.getDefaultJDFVersion().getValue();
            }

            i--; // must be removed if unknown is removed
            return(i);
        }
Example #2
0
        public virtual void testInvalidNameSpace()
        {
            JDFDoc     doc = new JDFDoc("JDF");
            JDFElement e   = doc.getJDFRoot();
            string     s   = JDFConstants.JDFNAMESPACE;

            s = StringUtil.replaceString(s, "_1_1", "_1_3");
            JDFElement e2 = (JDFElement)e.appendElement("ResourcePool", s);

            Assert.IsTrue(e2.getInvalidAttributes(EnumValidationLevel.Incomplete, true, 9999).Contains("xmlns"));
            e2 = (JDFElement)e.appendElement("ResourceLinkPool", "www.cip4.org");
            Assert.IsTrue(e2.getInvalidAttributes(EnumValidationLevel.Incomplete, true, 9999).Contains("xmlns"));
        }
Example #3
0
 public virtual void testUniqueID()
 {
     // Java to C# Conversion, Test taking too long, reduce count from original 200,000 for now
     SupportClass.HashSetSupport m = new SupportClass.HashSetSupport();
     for (int i = 0; i < 1000; i++)
     {
         string s = JDFElement.uniqueID(0);
         if (m.Contains(s))
         {
             Assert.Fail("oops");
         }
         m.Add(s);
     }
 }
Example #4
0
        public override void setUp()
        {
            // TODO Auto-generated method stub
            base.setUp();
            JDFElement.setLongID(false);
            JDFNode     n = new JDFDoc("JDF").getJDFRoot();
            JDFResource r = n.addResource(ElementName.COMPONENT, EnumUsage.Output);

            rl = n.getLink(r, null);
            JDFAttributeMap s1Map = new JDFAttributeMap(EnumPartIDKey.SheetName, "S1");

            rl.setAmount(10, s1Map);
            pa = rl.getAmountPool().getPartAmount(s1Map);
        }
Example #5
0
        public virtual void testGetParentJDFStatic()
        {
            JDFDoc     d    = new JDFDoc("JDF");
            JDFElement root = d.getJDFRoot();

            Assert.IsNull(JDFElement.getParentJDF(root));
            Assert.IsNull(JDFElement.getParentJDF(null));
            KElement k = root.appendElement("NodeInfo");

            Assert.AreEqual(root, JDFElement.getParentJDF(k));
            k = k.appendElement("foo:Bar", "www.foo.com");
            Assert.AreEqual(root, JDFElement.getParentJDF(k));
            k = root.appendElement("JDF");
            Assert.AreEqual(root, JDFElement.getParentJDF(k));
        }
Example #6
0
        public virtual void testCopyElement()
        {
            JDFDoc     d  = new JDFDoc("d1");
            JDFElement e  = (JDFElement)d.getRoot();
            JDFDoc     d2 = new JDFDoc("d2");
            JDFElement e2 = (JDFElement)d2.getRoot();
            KElement   e3 = e.copyElement(e2, null);
            JDFParser  p  = new JDFParser();
            JDFDoc     dp = p.parseString("<Device xmlns=\"www.CIP4.org/JDFSchema_1_1\"/>");
            KElement   ep = dp.getRoot();
            KElement   e4 = e.copyElement(ep, null);

            Assert.AreEqual(e4.hasAttribute("xmlns"), ep.hasAttribute("xmlns"));
            Assert.AreEqual(e3.getNamespaceURI(), e.getNamespaceURI());
            Assert.IsFalse(d.ToString().IndexOf("xmlns=\"\"") >= 0);
        }
Example #7
0
        public virtual void testAppendElement()
        {
            JDFDoc   d = new JDFDoc("JDF");
            KElement r = d.getRoot();
            KElement e = r.appendElement("e");

            Assert.AreEqual(e.getNamespaceURI(), JDFElement.getSchemaURL());
            KElement foo = e.appendElement("pt:foo", "www.pt.com");

            Assert.AreEqual("www.pt.com", foo.getNamespaceURI());
            KElement bar = foo.appendElement("bar");

            Assert.IsNotNull(bar.getNamespaceURI());
            KElement foo2 = bar.appendElement("pt:foo", "www.pt.com");

            Assert.AreEqual("www.pt.com", foo2.getNamespaceURI());
        }
Example #8
0
        private void _setUp()
        {
            // setup the fixture
            string xmlFile = "bookintent.jdf";

            // test jdf functions
            // ==================
            JDFParser p = new JDFParser();

            m_jdfDoc = p.parseFile(sm_dirTestData + xmlFile);

            Assert.IsTrue(m_jdfDoc != null, sm_dirTestData + xmlFile + ": Parse Error");

            m_jdfRoot    = (JDFNode)m_jdfDoc.getRoot();
            m_kElement   = m_jdfRoot.getChildByTagName("Dimensions", "", 0, null, false, true);
            m_jdfElement = (JDFElement)m_kElement;
        }
Example #9
0
        public virtual void testRemoveAttributeStringString()
        {
            JDFParser p      = new JDFParser();
            JDFDoc    jdfDoc = p.parseFile(sm_dirTestData + "emptyAuthorAttribute.jdf");

            JDFElement root  = jdfDoc.getJDFRoot();
            KElement   kElem = root.getChildByTagName("Created", "", 0, null, false, true);

            bool before = kElem.hasAttribute("Author", "", false);

            Assert.IsTrue(before, "The Attribute 'Author' does not exist");

            if (before)
            {
                kElem.removeAttribute("Author", "");
                bool after = kElem.hasAttribute("Author", "", false);

                Assert.IsFalse(after, "The Attribute 'Author' was not removed");
            }
        }
Example #10
0
        public virtual void testSetEnumerationsAttribute()
        {
            JDFDoc     d    = new JDFDoc("JDF");
            JDFElement root = d.getJDFRoot();

            root.setEnumerationsAttribute("dummy", null, null);
            Assert.IsNull(root.getEnumerationsAttribute("dummy", null, EnumNodeStatus.Aborted, false));
            List <ValuedEnum> v = new List <ValuedEnum>();

            v.Add(EnumNodeStatus.Cleanup);
            v.Add(EnumNodeStatus.Completed);
            root.setEnumerationsAttribute("dummy", v, null);
            List <ValuedEnum> vTest = root.getEnumerationsAttribute("dummy", null, EnumNodeStatus.Aborted, false);

            Assert.AreEqual(v.Count, vTest.Count, "round trip enumerations, count doesn't match");
            for (int i = 0; i < v.Count; ++i)
            {
                Assert.AreEqual(v[i], vTest[i], "round trip enumerations, index: " + i + "doesn't match");
            }
        }
Example #11
0
        ///
        ///	 * <param name="schemaLocation"> </param>
        ///	 * <param name="documentClassName"> </param>
        ///	 * <param name="ErrorHandler"> default: initParser(null, DocumentJDFImpl.class.getName(), null); </param>
        ///
        private void initParser(string schemaLocation, string documentClassName)
        {
            m_SchemaLocation = schemaLocation;
            m_DocumentClass  = documentClassName;

            try
            {
                if (m_SchemaLocation == null || m_SchemaLocation.Equals(JDFConstants.EMPTYSTRING))
                {
                    this.setFeature("http://xml.org/sax/features/validation", false);
                    this.setFeature("http://apache.org/xml/features/validation/schema", false);
                }
                else
                {
                    if (!m_SchemaLocation.StartsWith(JDFElement.getSchemaURL()))
                    {
                        m_SchemaLocation = JDFElement.getSchemaURL() + " " + m_SchemaLocation;
                    }
                    this.setFeature("http://xml.org/sax/features/validation", true);
                    this.setFeature("http://apache.org/xml/features/validation/schema", true);
                    // this.setFeature(
                    // "http://apache.org/xml/features/validation/schema/element-default"
                    // , false);
                    // this.setFeature(
                    // "http://apache.org/xml/features/validation/schema/normalized-value"
                    // , false);
                    this.setProperty("http://apache.org/xml/properties/schema/external-schemaLocation", m_SchemaLocation);
                }

                // use our own JDF document for creating JDF elements
                this.setProperty("http://apache.org/xml/properties/dom/document-class-name", documentClassName);

                this.setFeature("http://apache.org/xml/features/dom/defer-node-expansion", false);
                this.setFeature("http://xml.org/sax/features/namespaces", true);
            }
            catch (Exception e)
            {
                m_lastExcept = e;
            }
        }
Example #12
0
        public virtual void testAppendAnchor()
        {
            JDFDoc     doc = new JDFDoc("JDF");
            JDFElement e   = doc.getJDFRoot();

            SupportClass.HashSetSupport m = new SupportClass.HashSetSupport();
            KElement e2 = e.appendElement("e2");

            // Java to C# Conversion - Divide number of tests by 1000 for now
            for (int i = 0; i < 10; i++)
            {
                JDFElement appendElement = (JDFElement)e2.appendElement("FooBar");
                string     s             = appendElement.appendAnchor(null);
                if (m.Contains(s))
                {
                    Assert.Fail("oops");
                }
                Assert.AreEqual(s, appendElement.getID());
                Assert.IsTrue(s.IndexOf("..") < 0);
                m.Add(s);
            }
        }
Example #13
0
        public virtual void testIncludesMatchingAttribute()
        {
            _setUp();

            Assert.IsTrue(m_jdfElement.includesMatchingAttribute("Range", "600 800", AttributeInfo.EnumAttributeType.XYPairRangeList), "isInside (600 800) = ");
            Assert.IsFalse(m_jdfElement.includesMatchingAttribute("Range", "500 700", AttributeInfo.EnumAttributeType.XYPairRangeList), "isOutside(500 700) = ");

            JDFDoc     d = new JDFDoc("JDF");
            JDFElement e = d.getJDFRoot();

            e.setAttribute("abc", "a b c");
            Assert.IsTrue(e.includesMatchingAttribute("abc", "a", EnumAttributeType.NMTOKENS), "b");
            Assert.IsTrue(e.includesMatchingAttribute("abc", "b", EnumAttributeType.NMTOKENS), "b");
            Assert.IsTrue(e.includesMatchingAttribute("abc", "c", EnumAttributeType.NMTOKENS), "b");
            Assert.IsFalse(e.includesMatchingAttribute("abc", "d", EnumAttributeType.NMTOKENS), "b");
            e.setAttribute("intlist", "-1 3 5");
            Assert.IsTrue(e.includesMatchingAttribute("intlist", "-1", EnumAttributeType.IntegerList));
            Assert.IsTrue(e.includesMatchingAttribute("intlist", "3", EnumAttributeType.IntegerList));
            Assert.IsTrue(e.includesMatchingAttribute("intlist", "5", EnumAttributeType.IntegerList));
            Assert.IsFalse(e.includesMatchingAttribute("intlist", "4", EnumAttributeType.IntegerList));
            Assert.IsFalse(e.includesMatchingAttribute("intlist", "8", EnumAttributeType.IntegerList));
        }
Example #14
0
        public virtual void testDefaultVersion()
        {
            JDFDoc  doc = new JDFDoc("JDF");
            JDFNode n   = doc.getJDFRoot();

            Assert.AreEqual(n.getVersion(true), EnumVersion.Version_1_3);
            JDFElement.setDefaultJDFVersion(EnumVersion.Version_1_2);
            n.setType("ProcessGroup", true);
            n = n.addJDFNode("Combined");
            Assert.AreEqual(EnumVersion.Version_1_3, n.getVersion(true));

            doc = new JDFDoc("JDF");
            n   = doc.getJDFRoot();
            Assert.AreEqual(EnumVersion.Version_1_2, n.getVersion(true));
            n.setType("ProcessGroup", true);
            n = n.addJDFNode("Combined");
            Assert.AreEqual(EnumVersion.Version_1_2, n.getVersion(true));

            doc = new JDFDoc("JMF");
            JDFJMF jmf = doc.getJMFRoot();

            Assert.AreEqual(EnumVersion.Version_1_2, jmf.getVersion(true));
        }
Example #15
0
 public static void setDefaultVersion(EnumVersion v)
 {
     JDFElement.setDefaultJDFVersion(v);
 }
Example #16
0
 public static int getDefaultVersion()
 {
     return(JDFElement.getDefaultJDFVersion().getValue() - 1);
 }
Example #17
0
 public virtual void testGetValueForNewAttribute()
 {
     Assert.IsTrue(JDFElement.getValueForNewAttribute(null, "ID").StartsWith("I"));
 }