01: /**
02: * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
03: */package test.net.sourceforge.pmd.jaxen;
04:
05: import static org.junit.Assert.assertEquals;
06: import net.sourceforge.pmd.ast.ASTPrimaryPrefix;
07: import net.sourceforge.pmd.jaxen.Attribute;
08:
09: import org.junit.Test;
10:
11: import java.lang.reflect.Method;
12:
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(
35: AttributeTest.class);
36: }
37: }
|