// Parse test cases for each question
NodeList testCaseNodes = (NodeList) xpath.evaluate("./TestCase", q, XPathConstants.NODESET);
for (int j = 0; j < testCaseNodes.getLength(); j++)
{
TestCase tc = new TestCase();
Node t = testCaseNodes.item(j);
String value = xpath.evaluate("./Value/@value", t);
tc.setValue(new BigDecimal(value));
NodeList tcInputs = (NodeList) xpath.evaluate("./input", t, XPathConstants.NODESET);
for (int k = 0; k < tcInputs.getLength(); k++)
{
Node inputNode = tcInputs.item(k);
String input = inputNode.getTextContent();
//System.out.println("Input: " + input);
tc.addInput(input);
}
NodeList tcOutputs = (NodeList) xpath.evaluate("./output", t, XPathConstants.NODESET);
for (int k = 0; k < tcOutputs.getLength(); k++)
{
Node outputNode = tcOutputs.item(k);
String output = outputNode.getTextContent();
//System.out.println("Expected Output: " + output);
tc.addOutput(output);
}
NodeList tcExcludes = (NodeList) xpath.evaluate("./exclude", t, XPathConstants.NODESET);
for (int k = 0; k < tcExcludes.getLength(); k++)
{
Node outputNode = tcExcludes.item(k);
String exclude = outputNode.getTextContent();
//System.out.println("Exclusion: " + exclude);
tc.addExclusion(exclude);
}
tx.begin();
em.persist(tc);
tx.commit();
quest.addTestCase(tc);