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