public void testRemoveByIndex()
{
final Document oldDocument = new Document();
final Node oldParent = new Node();
oldDocument.addChild(oldParent);
final Elements<Node> oldElements = new Nodes(oldParent);
final Document document = new Document();
final Node parent = new Node();
document.addChild(parent);
final Elements<Node> elements = new Nodes(parent);
final Node child = new Node();
child.setId("ID");
child.setSid("SID");
oldElements.add(child);
assertTrue(elements.add(child));
assertSame(document, child.getDocument());
assertSame(parent, child.getParent());
assertSame(child, document.getById("ID"));
assertSame(child, document.getBySid("SID"));
assertSame(child, parent.getBySid("SID"));
assertSame(child, elements.remove(0));
// Check if node was correctly detached from elements
assertEquals(0, elements.size());
assertNull(child.getParent());
assertNull(child.getDocument());
assertNull(document.getById("ID"));
assertNull(document.getBySid("SID"));
assertNull(parent.getBySid("SID"));