View Javadoc

1   /**
2    * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3    */
4   package net.sourceforge.pmd.symboltable;
5   
6   import static org.junit.Assert.assertEquals;
7   
8   import java.util.ArrayList;
9   import java.util.List;
10  
11  import net.sourceforge.pmd.lang.java.ast.ASTVariableDeclaratorId;
12  import net.sourceforge.pmd.lang.java.symboltable.ImageFinderFunction;
13  import net.sourceforge.pmd.lang.java.symboltable.VariableNameDeclaration;
14  import net.sourceforge.pmd.lang.symboltable.NameDeclaration;
15  
16  import org.junit.Test;
17  public class ImageFinderFunctionTest {
18  
19      @Test
20      public void testSingleImage() {
21          ImageFinderFunction f = new ImageFinderFunction("foo");
22          ASTVariableDeclaratorId node = new ASTVariableDeclaratorId(1);
23          node.setImage("foo");
24          NameDeclaration decl = new VariableNameDeclaration(node);
25          f.applyTo(decl);
26          assertEquals(decl, f.getDecl());
27      }
28  
29      @Test
30      public void testSeveralImages() {
31          List<String> imgs = new ArrayList<String>();
32          imgs.add("Foo.foo");
33          imgs.add("foo");
34          ImageFinderFunction f = new ImageFinderFunction(imgs);
35          ASTVariableDeclaratorId node = new ASTVariableDeclaratorId(1);
36          node.setImage("foo");
37          NameDeclaration decl = new VariableNameDeclaration(node);
38          f.applyTo(decl);
39          assertEquals(decl, f.getDecl());
40      }
41  
42      public static junit.framework.Test suite() {
43          return new junit.framework.JUnit4TestAdapter(ImageFinderFunctionTest.class);
44      }
45  }