View Javadoc
1   /**
2    * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3    */
4   package net.sourceforge.pmd.testframework;
5   
6   import static org.junit.Assert.assertEquals;
7   
8   import java.io.IOException;
9   import java.util.List;
10  
11  import net.sourceforge.pmd.cpd.SourceCode;
12  import net.sourceforge.pmd.cpd.TokenEntry;
13  import net.sourceforge.pmd.cpd.Tokenizer;
14  import net.sourceforge.pmd.cpd.Tokens;
15  
16  /**
17   * @author Romain PELISSE, belaran@gmail.com
18   *
19   */
20  public abstract class AbstractTokenizerTest {
21  
22      protected int expectedTokenCount;
23      protected Tokenizer tokenizer;
24      protected SourceCode sourceCode;
25  
26      public abstract void buildTokenizer() throws IOException;
27  
28      public abstract String getSampleCode() throws IOException;
29  
30      protected void tokenizeTest() throws IOException {
31          Tokens tokens = new Tokens();
32          tokenizer.tokenize(sourceCode, tokens);
33          List<TokenEntry> entries = tokens.getTokens();
34          assertEquals(expectedTokenCount, entries.size());
35      }
36  
37  }