1   package test.net.sourceforge.pmd;
2   
3   import static org.junit.Assert.assertEquals;
4   import net.sourceforge.pmd.SourceType;
5   
6   import org.junit.Test;
7   import org.junit.runner.RunWith;
8   import org.junit.runners.Parameterized;
9   import org.junit.runners.Parameterized.Parameters;
10  
11  import java.util.Arrays;
12  import java.util.Collection;
13  
14  import junit.framework.JUnit4TestAdapter;
15  
16  @RunWith(Parameterized.class)
17  public class SourceTypeTest {
18  
19      private String id;
20  
21      private SourceType expected;
22  
23      public SourceTypeTest(String id, SourceType expected) {
24          this.id = id;
25          this.expected = expected;
26      }
27  
28      @Parameters
29      public static Collection data() {
30          return Arrays.asList(new Object[][] { 
31                  { "java 1.3", SourceType.JAVA_13 }, 
32                  { "java 1.4", SourceType.JAVA_14 }, 
33                  { "java 1.5", SourceType.JAVA_15 }, 
34                  { "java 1.6", SourceType.JAVA_16 },
35                  { "java 1.7", SourceType.JAVA_17 },
36              });
37      }
38  
39      @Test
40      public void testGetSourceTypeForId() {
41          assertEquals(expected, SourceType.getSourceTypeForId(id));
42      }
43  
44      public static junit.framework.Test suite() {
45          return new JUnit4TestAdapter(SourceTypeTest.class);
46      }
47  }