1 package jester.tests; 2 3 import jester.*; 4 5 import java.util.*; 6 import junit.framework.TestCase; 7 8 public class IgnoreListTest extends TestCase { 9 10 public IgnoreListTest(String arg0) { 11 super(arg0); 12 } 13 14 public static void main(String [] args) { 15 junit.awtui.TestRunner.run(IgnoreListTest.class); 16 } 17 18 public void testReadingEmptyIgnoreValues() throws ConfigurationException { 19 List expectedIgnorePairs = new ArrayList(); 20 String ignoreFileContents = ""; 21 IgnoreList ignoreList = new IgnoreList(ignoreFileContents); 22 assertEquals(expectedIgnorePairs, ignoreList.ignorePairs()); 23 } 24 25 public void testReadingIgnoreValues() throws ConfigurationException { 26 List expectedIgnorePairs = new ArrayList(); 27 expectedIgnorePairs.add(ignorePair("/*", "*/")); 28 String ignoreFileContents = "%/*%*/"; 29 IgnoreList ignoreList = new IgnoreList(ignoreFileContents); 30 assertEquals(expectedIgnorePairs, ignoreList.ignorePairs()); 31 } 32 33 public void testReadingIgnoreValuesEndOfLineSpecialCase() throws ConfigurationException { 34 List expectedIgnorePairs = new ArrayList(); 35 expectedIgnorePairs.add(ignorePair("//", "\n")); 36 String ignoreFileContents = "%//%\\n"; 37 IgnoreList ignoreList = new IgnoreList(ignoreFileContents); 38 assertEquals(expectedIgnorePairs, ignoreList.ignorePairs()); 39 } 40 41 public void testReadingMultipleIgnoreValues() throws ConfigurationException { 42 List expectedIgnorePairs = new ArrayList(); 43 expectedIgnorePairs.add(ignorePair("/*", "*/")); 44 expectedIgnorePairs.add(ignorePair("//jester_ignore_start", "//jester_ignore_end")); 45 String ignoreFileContents = "%/*%*/" + "\n" + "&//jester_ignore_start&//jester_ignore_end"; 46 IgnoreList ignoreList = new IgnoreList(ignoreFileContents); 47 assertEquals(expectedIgnorePairs, ignoreList.ignorePairs()); 48 } 49 50 public void testReadingMultipleIgnoreBlankLines() throws ConfigurationException { 51 List expectedIgnorePairs = new ArrayList(); 52 expectedIgnorePairs.add(ignorePair("/*", "*/")); 53 expectedIgnorePairs.add(ignorePair("//jester_ignore_start", "//jester_ignore_end")); 54 String ignoreFileContents = "%/*%*/" + "\n\n\n" + "&//jester_ignore_start&//jester_ignore_end"; 55 IgnoreList ignoreList = new IgnoreList(ignoreFileContents); 56 assertEquals(expectedIgnorePairs, ignoreList.ignorePairs()); 57 } 58 59 public void testReadingIncorrectFile() { 60 String ignoreFileContents = "%/*"; 61 try { 62 IgnoreList ignoreList = new IgnoreList(ignoreFileContents); 63 ignoreList.ignorePairs(); 64 } catch (ConfigurationException ex) { 65 } 67 } 68 69 private IgnorePair ignorePair(String start, String end) { 70 return new IgnorePair(start, end); 71 } 72 } 73 | Popular Tags |