1 17 18 package org.apache.tools.ant.taskdefs; 19 20 import org.apache.tools.ant.Project; 21 22 import junit.framework.TestCase; 23 24 29 public class RmicTest extends TestCase { 30 31 private Project project; 32 private Rmic rmic; 33 34 public RmicTest(String name) { 35 super(name); 36 } 37 38 public void setUp() { 39 project = new Project(); 40 project.init(); 41 rmic = new Rmic(); 42 rmic.setProject(project); 43 } 44 45 48 public void testCompilerArg() { 49 String [] args = rmic.getCurrentCompilerArgs(); 50 assertNotNull(args); 51 assertEquals("no args", 0, args.length); 52 53 Rmic.ImplementationSpecificArgument arg = rmic.createCompilerArg(); 54 String ford = "Ford"; 55 String prefect = "Prefect"; 56 String testArg = ford + " " + prefect; 57 arg.setValue(testArg); 58 args = rmic.getCurrentCompilerArgs(); 59 assertEquals("unconditional single arg", 1, args.length); 60 assertEquals(testArg, args[0]); 61 62 arg.setCompiler("weblogic"); 63 args = rmic.getCurrentCompilerArgs(); 64 assertNotNull(args); 65 assertEquals("implementation is weblogic but build.rmic is null", 66 0, args.length); 67 68 project.setProperty("build.rmic", "sun"); 69 args = rmic.getCurrentCompilerArgs(); 70 assertNotNull(args); 71 assertEquals("implementation is weblogic but build.rmic is sun", 72 0, args.length); 73 74 project.setProperty("build.rmic", "weblogic"); 75 args = rmic.getCurrentCompilerArgs(); 76 assertEquals("both are weblogic", 1, args.length); 77 assertEquals(testArg, args[0]); 78 } 79 80 83 public void testCompilerAttribute() { 84 String compiler = rmic.getCompiler(); 86 assertNotNull(compiler); 87 assertTrue("default value", 88 "sun".equals(compiler) || "kaffe".equals(compiler)); 89 90 project.setNewProperty("build.rmic", "weblogic"); 91 compiler = rmic.getCompiler(); 92 assertNotNull(compiler); 93 assertEquals("weblogic", compiler); 94 95 rmic.setCompiler("kaffe"); 97 compiler = rmic.getCompiler(); 98 assertNotNull(compiler); 99 assertEquals("kaffe", compiler); 100 } 101 102 } 103 | Popular Tags |