1
2
3
4 package net.sourceforge.pmd.lang.ast.xpath;
5
6 import static org.junit.Assert.assertNotNull;
7 import static org.junit.Assert.assertSame;
8 import static org.junit.Assert.fail;
9 import net.sourceforge.pmd.lang.ast.Node;
10 import net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit;
11 import net.sourceforge.pmd.lang.java.ast.DummyJavaNode;
12
13 import org.junit.Test;
14
15
16
17
18 public class DocumentNavigatorTest {
19
20 @Test
21 public void getDocumentNode() {
22 DocumentNavigator nav = new DocumentNavigator();
23
24 try {
25 nav.getDocumentNode(null);
26 fail();
27 } catch (RuntimeException e) {
28 assertNotNull(e);
29 }
30
31 Node root = new ASTCompilationUnit(1);
32 Node n = new DummyJavaNode(1);
33 root.jjtAddChild(n, 0);
34 n.jjtSetParent(root);
35 assertSame(root, nav.getDocumentNode(n));
36 }
37 }