public override void setUp() { base.setUp(); JDFElement.setLongID(false); JDFDoc doc = new JDFDoc("Device"); device = (JDFDevice)doc.getRoot(); devicecap = device.appendDeviceCap(); devicecap.setCombinedMethod(EnumCombinedMethod.None); devicecap.setTypeExpression("(fnarf)|(blub)"); devicecap.setTypes(new VString("fnarf blub", null)); JDFDevCapPool dcp = devicecap.appendDevCapPool(); JDFDevCaps dcs = devicecap.appendDevCaps(); dcs.setContext(EnumContext.Resource); dcs.setName("Component"); dcs.setRequired(true); JDFDevCap dc = dcp.appendDevCap(); dc.setID("dc_Component"); dcs.setDevCapRef(dc); compState = dc.appendEnumerationState("ComponentType"); ptState = dc.appendNameState("ProductType"); }
public virtual void testGetCombinedMethod() { JDFDoc d = new JDFDoc(ElementName.DEVICECAP); JDFDeviceCap dc = (JDFDeviceCap)d.getRoot(); List <ValuedEnum> v = new List <ValuedEnum>(); v.Add(EnumCombinedMethod.None); CollectionAssert.AreEqual(v, dc.getCombinedMethod(), "default is none"); }
public override void setUp() { base.setUp(); JDFDoc doc = new JDFDoc("JMF"); JDFJMF jmf = doc.getJMFRoot(); JDFResponse resp = (JDFResponse)jmf.appendMessageElement(EnumFamily.Response, JDFMessage.EnumType.KnownDevices); deviceCap = resp.appendDeviceList().appendDeviceInfo().appendDevice().appendDeviceCap(); deviceCap.appendBooleanState("Template"); }
public virtual void testGetExecutableJDF() { string docTest = "MISPrepress_ICS_Minimal.jdf"; string docDevCap = "DevCaps_Product_MISPrepress_ICS_Minimal.jdf"; // parse input file JDFParser p = new JDFParser(); JDFDoc jmfDevCap = p.parseFile(sm_dirTestData + docDevCap); JDFJMF jmfRoot = null; Assert.IsNotNull(jmfDevCap, "Parse of file " + docDevCap + " failed"); jmfRoot = jmfDevCap.getJMFRoot(); Assert.IsNotNull(jmfRoot, "jmfRoot == null Can't start Test"); XMLDoc docOutDevCap = jmfRoot.getOwnerDocument_KElement(); docOutDevCap.write2File(sm_dirTestDataTemp + "_" + docDevCap, 0, true); JDFDoc jdfTest = p.parseFile(sm_dirTestData + docTest); JDFNode jdfRoot = jdfTest.getJDFRoot(); Assert.IsTrue(jdfRoot != null, "jdfRoot is null"); if (jdfRoot != null) { jdfRoot.getOwnerDocument_KElement(); JDFDeviceCap deviceCap = (JDFDeviceCap)jmfRoot.getChildByTagName("DeviceCap", null, 0, null, false, true); EnumFitsValue testlists = EnumFitsValue.Allowed; EnumValidationLevel level = KElement.EnumValidationLevel.Complete; VElement vExecNodes = deviceCap.getExecutableJDF(jdfRoot, testlists, level); if (vExecNodes == null) { Console.WriteLine(docDevCap + ": found No matching JDFNode"); } else { for (int n = 0; n < vExecNodes.Count; n++) { // XMLDoc docExecNodes = ((JDFNode) // vExecNodes.elementAt(n)).getOwnerDocument_KElement(); // docExecNodes.write2File ("temp\\" + "_" + docTest // +"_ExecNode" + (n+1) + // ".jdf", 0); Console.WriteLine(vExecNodes[n]); } } XMLDoc testResult = deviceCap.getBadJDFInfo(jdfRoot, testlists, level); if (testResult != null) { testResult.write2File(sm_dirTestDataTemp + "_BugReport.xml", 0, true); } } }
public virtual void testAppendDevCapInPool_DeviceCap() { JDFDoc doc = new JDFDoc("DeviceCap"); JDFDeviceCap ms = (JDFDeviceCap)doc.getRoot(); JDFDevCaps dcs = ms.appendDevCaps(); dcs.setName("foo"); JDFDevCap dc = dcs.appendDevCapInPool(); Assert.AreEqual(dc, dcs.getDevCap()); Assert.AreEqual(dc.getName(), dcs.getName()); }
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")); }
public virtual void testDeviceCapIsValid() { JDFParser p = new JDFParser(); string docDevCap = "DevCaps_Product_MISPrepress_ICS_Minimal.jdf"; JDFDoc jmfDevCap = p.parseFile(sm_dirTestData + docDevCap); Assert.IsNotNull(jmfDevCap, "Parse of file " + docDevCap + " failed"); JDFJMF jmfRoot = jmfDevCap.getJMFRoot(); Assert.IsNotNull(jmfRoot, "jmfRoot == null Can't start Test"); JDFDeviceCap deviceCap = (JDFDeviceCap)jmfRoot.getChildByTagName("DeviceCap", "", 0, null, false, true); Assert.IsTrue(deviceCap.isValid(KElement.EnumValidationLevel.Incomplete)); }
public virtual void testGetBadJDFInfo() { JDFDoc d = JDFDoc.parseFile(sm_dirTestData + "Device_Elk_ConventionalPrinting2.xml"); JDFDeviceCap dc = (JDFDeviceCap)d.getRoot().getXPathElement("/JMF/Response/DeviceList/DeviceInfo/Device/DeviceCap"); Assert.IsNotNull(dc); JDFDoc d2 = JDFDoc.parseFile(sm_dirTestData + "Elk_ConventionalPrinting.jdf"); JDFNode cpNode = d2.getJDFRoot(); Assert.IsNotNull(cpNode); XMLDoc outDoc = dc.getBadJDFInfo(cpNode, EnumFitsValue.Allowed, EnumValidationLevel.Complete); Assert.IsNull(outDoc, "devcaps are consistently evaluated"); }
/// /// <summary> * Get all DeviceCap from the current element /// * </summary> /// * <returns> Collection<JDFDeviceCap> </returns> /// public virtual ICollection <JDFDeviceCap> getAllDeviceCap() { List <JDFDeviceCap> v = new List <JDFDeviceCap>(); JDFDeviceCap kElem = (JDFDeviceCap)getFirstChildElement(ElementName.DEVICECAP, null); while (kElem != null) { v.Add(kElem); kElem = (JDFDeviceCap)kElem.getNextSiblingElement(ElementName.DEVICECAP, null); } return(v); }
public virtual void testUsageCounterDevCaps() { JDFDoc duc = new JDFDoc("DeviceCap"); JDFDeviceCap devicecap = (JDFDeviceCap)duc.getRoot(); JDFDevCaps dcs = devicecap.appendDevCaps(); dcs.setName(ElementName.USAGECOUNTER); JDFDevCap dc = dcs.appendDevCapInPool(); dc.setMinOccurs(3); dc.setMaxOccurs(3); JDFNameState counterID = dc.appendNameState(AttributeName.COUNTERID); counterID.setAllowedValueList(new VString("ID_Black ID_Color ID_Total", null)); counterID.setListType(EnumListType.SingleValue); duc.write2File(sm_dirTestDataTemp + "DevCapUsageCounter.jdf", 2, false); }
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 }
public virtual void testGetModuleAvailability() { JDFDoc d = new JDFDoc("DeviceCap"); JDFDeviceCap deviceCap = (JDFDeviceCap)d.getRoot(); JDFModuleCap mc = deviceCap.appendModulePool().appendModuleCap(); mc.setID("i"); mc.setAvailability(EnumAvailability.NotLicensed); JDFDevCap dc = deviceCap.appendDevCaps().appendDevCap(); Assert.AreEqual(EnumAvailability.Installed, dc.getModuleAvailability()); dc.setAvailability(EnumAvailability.Module); Assert.AreEqual(EnumAvailability.Module, dc.getAvailability()); Assert.IsNull(dc.getModuleAvailability()); dc.setModuleRefs(new VString("i", null)); Assert.AreEqual(EnumAvailability.NotLicensed, dc.getModuleAvailability()); }
/// /// <summary> * return all deviceCap elements that correspond to testRoot /// * </summary> /// * <param name="testRoot"> the JDF or JMF to test /// * </param> /// * <returns> VElement - the list of matching devicecap nodes, null if none found /// * </returns> /// public virtual VElement getMatchingDeviceCapVector(JDFNode testRoot, bool bLocal) { VElement vDeviceCap = getChildElementVector(ElementName.DEVICECAP, null, null, false, -1, false); if (vDeviceCap == null || vDeviceCap.IsEmpty()) { return(null); } VElement vRet = new VElement(); for (int i = 0; i < vDeviceCap.Count; i++) { JDFDeviceCap dc = (JDFDeviceCap)vDeviceCap[i]; if (dc.matchesType(testRoot, bLocal)) { vRet.Add(dc); } } return(vRet.IsEmpty() ? null : vRet); }
public virtual void testAppendModuleRef() { JDFDoc d = new JDFDoc("DeviceCap"); JDFDeviceCap deviceCap = (JDFDeviceCap)d.getRoot(); JDFDevCap dc = deviceCap.appendDevCaps().appendDevCap(); dc.setAvailability(EnumAvailability.NotInstalled); Assert.AreEqual(EnumAvailability.NotInstalled, dc.getAvailability()); Assert.AreEqual(EnumAvailability.NotInstalled, dc.getModuleAvailability()); JDFModuleCap mc = dc.appendModuleRef("MyDev"); mc.setAvailability(EnumAvailability.Disabled); Assert.AreEqual(EnumAvailability.Module, dc.getAvailability()); Assert.AreEqual(EnumAvailability.Disabled, dc.getModuleAvailability()); Assert.AreEqual(EnumAvailability.Disabled, mc.getAvailability()); mc = dc.appendModuleRef("MyOtherDev"); mc.setAvailability(EnumAvailability.NotInstalled); Assert.AreEqual(EnumAvailability.NotInstalled, dc.getModuleAvailability()); Assert.AreEqual(EnumAvailability.NotInstalled, mc.getAvailability()); }
public virtual void testGetMessageServiceForJMFType() { JDFMessage m = JDFJMF.createJMF(JDFMessage.EnumFamily.Acknowledge, EnumType.KnownDevices).getMessageElement(null, null, 0); JDFResponse resp = JDFJMF.createJMF(JDFMessage.EnumFamily.Response, EnumType.KnownMessages).getResponse(0); JDFMessageService ms = resp.appendMessageService(); ms.setType(EnumType.AbortQueueEntry); ms.setAcknowledge(true); Assert.IsNull(JDFDeviceCap.getMessageServiceForJMFType(m, resp), "wrong type"); JDFMessageService ms2 = resp.appendMessageService(); ms2.setType(EnumType.KnownDevices); ms2.setQuery(true); Assert.IsNull(JDFDeviceCap.getMessageServiceForJMFType(m, resp), "wrong type"); JDFMessageService ms3 = resp.appendMessageService(); ms3.setType(EnumType.KnownDevices); ms3.setAcknowledge(true); Assert.AreEqual(ms3, JDFDeviceCap.getMessageServiceForJMFType(m, resp), "family and type match"); }
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)); }
/// /// <summary> * Gets of jdfRoot a vector of all executable nodes (jdf root or children nodes that this Device may execute) /// * </summary> /// * <param name="jdfRoot"> the node we test </param> /// * <param name="testlists"> testlists that are specified for the State elements (FitsValue_Allowed or FitsValue_Present)<br> /// * Will be used in fitsValue method of the State class. </param> /// * <param name="level"> validation level </param> /// * <returns> VElement - vector of executable JDFNodes </returns> /// public virtual VElement getExecutableJDF(JDFNode docRoot, EnumFitsValue testlists, EnumValidationLevel validationLevel) { VElement vDC = getChildElementVector(ElementName.DEVICECAP, null, null, true, -1, false); if (vDC == null || vDC.IsEmpty()) { return(null); } VElement vn = new VElement(); for (int i = 0; i < vDC.Count; i++) { JDFDeviceCap dc = (JDFDeviceCap)vDC[i]; VElement executableJDF = dc.getExecutableJDF(docRoot, testlists, validationLevel); if (executableJDF != null) { vn.addAll(executableJDF); } } vn.unify(); return(vn.IsEmpty() ? null : vn); }
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")); }
public override void setUp() { JDFDoc doc = new JDFDoc("Device"); device = (JDFDevice)doc.getRoot(); base.setUp(); { devicecap = device.appendDeviceCap(); devicecap.setCombinedMethod(EnumCombinedMethod.None); devicecap.setTypeExpression("(fnarf)|(blub)"); devicecap.setTypes(new VString("fnarf blub", null)); devicecap.setGenericAttributes(new VString("*", null)); JDFDevCapPool dcp = devicecap.appendDevCapPool(); JDFDevCaps dcs = devicecap.appendDevCaps(); dcs.setContext(EnumContext.Element); dcs.setName("AuditPool"); dcs.setRequired(true); JDFDevCap dc = dcp.appendDevCap(); dc.setID("dc_AuditPool"); dcs.setDevCapRef(dc); dc = dc.appendDevCap(); dc.setName("Created"); dc.setID("dc_Created"); dcs = devicecap.appendDevCaps(); dcs.setContext(EnumContext.Element); dcs.setName("AncestorPool"); dc = dcs.appendDevCap(); dc.setMinOccurs(0); dc.setID("dc_AncestorPool"); JDFDevCap dc2 = dc.appendDevCap(); dc2.setID("dc_Ancestor"); dc2.setName("Ancestor"); for (int pu = 0; pu < 2; pu++) { dcs = devicecap.appendDevCaps(); dcs.setContext(EnumContext.Resource); dcs.setName("RunList"); dcs.setLinkUsage(EnumUsage.Input); dcs.setProcessUsage(pu == 0 ? "Document" : "Marks"); dc = dcs.appendDevCap(); if (pu == 0) { dc.setID("dc_RL_Doc"); dc.setMinOccurs(1); } else { dc.setID("dc_RL_Mark"); dc.setMinOccurs(0); } } dcs = devicecap.appendDevCaps(); dcs.setContext(EnumContext.Resource); dcs.setName("Layout"); dcs.setLinkUsage(EnumUsage.Input); dc = dcs.appendDevCap(); dc.setID("dc_Layout"); dc.setMinOccurs(1); JDFDevCap coDC = dc.appendDevCap(); coDC.setName(ElementName.CONTENTOBJECT); coDC.setMinOccurs(2); JDFNumberState st = coDC.appendNumberState(AttributeName.CTM); st.setRequired(true); st.setListType(EnumListType.List); st.setMinOccurs(6); st.setMaxOccurs(6); st.setHasDefault(true); st.setAttribute("DefaultValue", "1 0 0 1 1 1"); dcs = devicecap.appendDevCaps(); dcs.setContext(EnumContext.Link); dcs.setLinkUsage(EnumUsage.Input); dcs.setName("Layout"); dc = dcs.appendDevCap(); dc.setID("dc_LayoutLink"); dcs = devicecap.appendDevCaps(); dcs.setContext(EnumContext.Element); dcs.setName("JDF"); dc = dcp.appendDevCap(); dc.setID("dc_JDF"); dcs.setDevCapRef(dc); doc.write2File(sm_dirTestDataTemp + "devCapDefaults.jdf", 2, false); } { devicecapProduct = device.appendDeviceCap(); List <ValuedEnum> vMethods = new List <ValuedEnum>(); vMethods.Add(EnumCombinedMethod.None); vMethods.Add(EnumCombinedMethod.ProcessGroup); vMethods.Add(EnumCombinedMethod.Combined); devicecapProduct.setCombinedMethod(vMethods); devicecapProduct.setTypeExpression("((fnarf)|(blub))( (fnarf)|(blub))*"); devicecapProduct.setTypes(new VString("fnarf blub", null)); JDFDevCapPool dcp = devicecapProduct.appendDevCapPool(); JDFDevCaps dcs = devicecap.appendDevCaps(); dcs.setContext(EnumContext.Element); dcs.setName("AuditPool"); dcs.setRequired(true); JDFDevCap dc = dcp.appendDevCap(); dc.setID("dc_AuditPool"); dcs.setDevCapRef(dc); dc = dc.appendDevCap(); dc.setName("Created"); dc.setID("dc_Created"); dcs = devicecap.appendDevCaps(); dcs.setContext(EnumContext.Resource); dcs.setName("Layout"); dcs.setLinkUsage(EnumUsage.Input); dc = dcs.appendDevCap(); dc.setID("dc_Layout"); dc.setMinOccurs(1); JDFDevCap coDC = dc.appendDevCap(); coDC.setName(ElementName.CONTENTOBJECT); coDC.setMinOccurs(2); coDC.setMaxOccurs(999); JDFNumberState st = coDC.appendNumberState(AttributeName.CTM); st.setRequired(true); st.setListType(EnumListType.List); st.setMinOccurs(6); st.setMaxOccurs(6); st.setHasDefault(true); st.setAttribute("DefaultValue", "1 0 0 1 1 1"); dcs = devicecap.appendDevCaps(); dcs.setContext(EnumContext.Link); dcs.setLinkUsage(EnumUsage.Input); dcs.setName("Layout"); dc = dcs.appendDevCap(); dc.setID("dc_LayoutLink"); dcs = devicecap.appendDevCaps(); dcs.setContext(EnumContext.Element); dcs.setName("JDF"); dc = dcp.appendDevCap(); dc.setID("dc_JDF"); dcs.setDevCapRef(dc); } }
/// /// <summary> * Composes a BugReport in XML form for the given JDFNode 'jdfRoot'. Gives a list of error messages for 'jdfRoot' /// * and every child rejected Node.<br> /// * Returns <code>null</code> if there are no errors. /// * </summary> /// * <param name="jdfRoot"> the node to test </param> /// * <param name="testlists"> testlists that are specified for the State elements (FitsValue_Allowed or FitsValue_Present)<br> /// * Will be used in fitsValue method of the State class. </param> /// * <param name="level"> validation level </param> /// * <returns> XMLDoc - XMLDoc output of the error messages. If XMLDoc is null there are no errors. </returns> /// public XMLDoc getBadJDFInfo(JDFNode jdfRoot, EnumFitsValue testlists, EnumValidationLevel level) { VElement vDC = getChildElementVector(ElementName.DEVICECAP, null, null, true, -1, false); if (vDC == null || vDC.IsEmpty()) { return(null); } VElement vn = new VElement(); for (int i = 0; i < vDC.Count; i++) { JDFDeviceCap dc = (JDFDeviceCap)vDC[i]; XMLDoc bugReport = dc.getBadJDFInfo(jdfRoot, testlists, level); if (bugReport == null) { return(null); } vn.addAll(bugReport.getRoot().getChildElementVector(null, null, null, true, -1, false)); } int vnSize = vn.Count; if (vnSize == 0) { return(null); } XMLDoc bugReport2 = new XMLDoc("BugReport", null); KElement root = bugReport2.getRoot(); bool bFit = false; for (int i = 0; i < vnSize; i++) { KElement e = vn[i]; if (JDFConstants.TRUE.Equals(e.getAttribute(JDFDeviceCap.FITS_TYPE))) { bFit = true; } } if (bFit) { for (int i = 0; i < vnSize; i++) { KElement e = vn[i]; if (JDFConstants.FALSE.Equals(e.getAttribute(JDFDeviceCap.FITS_TYPE))) { vn[i] = null; } } } for (int i = 0; i < vnSize; i++) { if (vn[i] != null) { root.moveElement(vn.item(i), null); } } return(bugReport2); }