1
2
3
4 package net.sourceforge.pmd.jaxen;
5
6 import static org.junit.Assert.assertEquals;
7 import net.sourceforge.pmd.lang.ast.xpath.Attribute;
8 import net.sourceforge.pmd.lang.java.ast.ASTPrimaryPrefix;
9
10 import org.junit.Test;
11
12 import java.lang.reflect.Method;
13 public class AttributeTest{
14
15 @Test
16 public void testConstructor() {
17 ASTPrimaryPrefix p = new ASTPrimaryPrefix(1);
18 p.testingOnly__setBeginLine(5);
19 Method[] methods = p.getClass().getMethods();
20 Method m = null;
21 for (int i = 0; i < methods.length; i++) {
22 if (methods[i].getName().equals("getBeginLine")) {
23 m = methods[i];
24 break;
25 }
26 }
27 Attribute a = new Attribute(p, "BeginLine", m);
28 assertEquals("BeginLine", a.getName());
29 assertEquals(5, a.getValue());
30 assertEquals("5", a.getStringValue());
31 assertEquals(p, a.getParent());
32 }
33
34 public static junit.framework.Test suite() {
35 return new junit.framework.JUnit4TestAdapter(AttributeTest.class);
36 }
37 }