1 package com.puppycrawl.tools.checkstyle.checks; 2 3 import com.puppycrawl.tools.checkstyle.BaseCheckTestCase; 4 import com.puppycrawl.tools.checkstyle.DefaultConfiguration; 5 6 public class RequiredRegexpCheckTest 7 extends BaseCheckTestCase 8 { 9 public void testExistingInDoc() 10 throws Exception 11 { 12 final String required = "Test case file"; 13 final DefaultConfiguration checkConfig = 14 createCheckConfig(RequiredRegexpCheck.class); 15 checkConfig.addAttribute("format", required); 16 final String [] expected = { 17 }; 18 verify(checkConfig, getPath("InputSemantic.java"), expected); 19 } 20 21 public void testExistingInCode() 22 throws Exception 23 { 24 final String required = "package"; 25 final DefaultConfiguration checkConfig = 26 createCheckConfig(RequiredRegexpCheck.class); 27 checkConfig.addAttribute("format", required); 28 final String [] expected = { 29 }; 30 verify(checkConfig, getPath("InputSemantic.java"), expected); 31 } 32 33 public void testMissing() 34 throws Exception 35 { 36 final String required = "This text is not in the file"; 37 final DefaultConfiguration checkConfig = 38 createCheckConfig(RequiredRegexpCheck.class); 39 checkConfig.addAttribute("format", required); 40 final String [] expected = { 41 "0: Required pattern '" + required + "' missing in file." 42 }; 43 verify(checkConfig, getPath("InputSemantic.java"), expected); 44 } 45 } 46 | Popular Tags |