public void loadTestProfiles() throws IOException, JDOMException { SAXBuilder parser = new SAXBuilder(); // load constraint profile. Document doc1 = parser.build(new File(traceDir + "SigConstProfile.xml")); for (Object o : doc1.getContent()) { Element root = (Element) o; if (!root.getName().equals("SigConstProfile")) continue; for (Object s : root.getContent()) { // for each SQL signature. if (!(s instanceof Element)) continue; Element sigConstElement = (Element) s; if (!sigConstElement.getName().equals("Signature")) continue; String sig = sigConstElement.getAttributeValue("Sig"); SigProfile profile = new SigProfile(sig); profile.procXMLSigConstProfileElement(sigConstElement); testProfiles.put(sig, profile); } } // load trace summary. Document doc2 = parser.build(new File(traceDir + "TraceSummary.xml")); for (Object o : doc2.getContent()) { Element root = (Element) o; if (!root.getName().equals("TraceSummary")) continue; for (Object s : root.getContent()) { // for each SQL signature. if (!(s instanceof Element)) continue; Element summary = (Element) s; if (!summary.getName().equals("Signature")) continue; String sig = summary.getAttributeValue("Sig"); SigProfile profile = testProfiles.get(sig); profile.procXMLTraceSumElement(summary); } } // prepare sessionVars set. for (String sig : testProfiles.keySet()) { for (String entry : testProfiles.get(sig).getEntries().keySet()) { // System.out.println(sig + " " + entry); Vector<RequestMessage> messageList = testProfiles.get(sig).getMessagesByEntry(entry); // System.out.println(messageList.size()); for (RequestMessage message : messageList) { String stateSig = _stateConstructor.genStateSig(message.getSessionVars()); if (!sessionVarsSet.containsKey(stateSig)) { if (!_stateConstructor.getStateSet().contains(stateSig)) { continue; } System.out.println("Loading state: " + stateSig); sessionVarsSet.put(stateSig, new HashSet<String>()); } sessionVarsSet.get(stateSig).add(message.getSessionVars()); } } } }
// generate the set of test request messages. public Vector<String> genTestParasSet(String sig, String entry, RequestMessage seed) { HashMap<String, String> parameters = _parser.parseInputParameters(seed.getInputParas()); HashMap<String, String> sessionVars = _parser.parseSession(seed.getSessionVars()); Vector<String> testParas = testProfiles.get(sig).getEntries().get(entry).genViolatedParas(parameters, sessionVars); return testParas; }