source: other-projects/trunk/gs3-release-maker/apache-ant-1.6.5/src/testcases/org/apache/tools/ant/taskdefs/RmicTest.java@ 14627

Last change on this file since 14627 was 14627, checked in by oranfry, 17 years ago

initial import of the gs3-release-maker

File size: 3.1 KB
Line 
1/*
2 * Copyright 2002,2004-2005 The Apache Software Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 */
17
18package org.apache.tools.ant.taskdefs;
19
20import org.apache.tools.ant.Project;
21
22import junit.framework.TestCase;
23
24/**
25 * Testcase for <rmic>.
26 *
27 * @since Ant 1.5
28 */
29public 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 /**
46 * Test nested compiler args.
47 */
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 /**
81 * Test compiler attribute.
82 */
83 public void testCompilerAttribute() {
84 // check defaults
85 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 // check attribute overrides build.compiler
96 rmic.setCompiler("kaffe");
97 compiler = rmic.getCompiler();
98 assertNotNull(compiler);
99 assertEquals("kaffe", compiler);
100 }
101
102}
Note: See TracBrowser for help on using the repository browser.