1 33 34 package edu.rice.cs.drjava.config; 35 import junit.framework.TestCase; 36 import java.io.*; 37 38 import edu.rice.cs.drjava.DrJavaTestCase; 39 40 43 public final class OptionMapLoaderTest extends DrJavaTestCase implements OptionConstants { 44 45 public OptionMapLoaderTest(String s) { super(s); } 46 47 public static class StringInputStream extends ByteArrayInputStream { 48 public StringInputStream(String s) { super(s.getBytes()); } 49 } 50 51 52 public static final String OPTION_DOC = 53 "# this is a fake header\n"+ 54 "this.is.a.real.key = value\n"+ 55 "indent.level = 1\n"+ 56 "javac.location = foo\n"+ 57 "extra.classpath = bam\n\n"; 58 59 public void testProperConfigSet() throws IOException { 60 checkSet(OPTION_DOC,new Integer (1), new File("foo"), 1); 61 } 62 63 private void checkSet(String set, Integer indent, File javac, int size) throws IOException { 64 StringInputStream is = new StringInputStream(set); 65 OptionMapLoader loader = new OptionMapLoader(is); 66 DefaultOptionMap map = new DefaultOptionMap(); 67 loader.loadInto(map); 68 assertEquals("indent (integer) option", map.getOption(INDENT_LEVEL),indent); 69 assertEquals("JAVAC", map.getOption(JAVAC_LOCATION),javac.getAbsoluteFile()); 70 assertEquals("size of extra-classpath vector", new Integer (size), 71 new Integer (map.getOption(EXTRA_CLASSPATH).size())); 72 } 73 74 public void testEmptyConfigSet() throws IOException { 75 checkSet("",INDENT_LEVEL.getDefault(), JAVAC_LOCATION.getDefault(), EXTRA_CLASSPATH.getDefault().size()); 76 } 77 } 78 | Popular Tags |