* Tests if sequence for NodeList is created correctly.
*
* @throws Exception
*/
public void testSequenceNodeValues() throws Exception {
Sequence sequence = factory.createSequence((NodeList) null);
assertSame("Sequence should be empty", sequence, Sequence.EMPTY);
final Node node = getNodeWithChildrenForSequence();
final NodeList listOfNodes = node.getChildNodes();
sequence = factory.createSequence(listOfNodes);
Node[] nodes = new Node[listOfNodes.getLength()];
for (int i = 0; i < listOfNodes.getLength(); i++) {
// store nodes for later comparision
nodes[i] = listOfNodes.item(i);
assertEquals("Sequence doesn't contains correct Values",
listOfNodes.item(i).getNodeName(),
((NodeValue)sequence.getItem(i + 1)).asW3CNode()
.getNodeName());
assertSame("Nodes from Sequence should be " +
"the same as used while creating an Sequence",
listOfNodes.item(i),
((NodeValue) sequence.getItem(i + 1)).asW3CNode());
}
// now change NodeList, this should left sequence unchanged
node.removeChild(nodes[0]);
assertSame("Removed from list of nodes node isn't exists in sequence",
nodes[0], ((NodeValue) sequence.getItem(1)).asW3CNode());
}