1 /**
2 * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3 */
4 package test.net.sourceforge.pmd.jaxen;
5
6 import static org.junit.Assert.assertEquals;
7 import net.sourceforge.pmd.ast.ASTPrimaryPrefix;
8 import net.sourceforge.pmd.jaxen.Attribute;
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(p, a.getParent());
31 }
32
33 public static junit.framework.Test suite() {
34 return new junit.framework.JUnit4TestAdapter(AttributeTest.class);
35 }
36 }