001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: *
017: */
018:
019: package org.apache.tools.ant.taskdefs;
020:
021: import org.apache.tools.ant.BuildFileTest;
022: import org.apache.tools.ant.BuildException;
023: import org.apache.tools.ant.taskdefs.rmic.RmicAdapterFactory;
024: import org.apache.tools.ant.taskdefs.rmic.DefaultRmicAdapter;
025:
026: /**
027: * Date: 04-Aug-2004
028: * Time: 22:15:46
029: */
030: public class RmicAdvancedTest extends BuildFileTest {
031:
032: public RmicAdvancedTest(String name) {
033: super (name);
034: }
035:
036: private final static String TASKDEFS_DIR = "src/etc/testcases/taskdefs/rmic/";
037:
038: /**
039: * The JUnit setup method
040: */
041: public void setUp() throws Exception {
042: super .setUp();
043: configureProject(TASKDEFS_DIR + "rmic.xml");
044: }
045:
046: /**
047: * The teardown method for JUnit
048: */
049: public void tearDown() {
050: executeTarget("teardown");
051: }
052:
053: /**
054: * verify that "default" binds us to the default compiler
055: */
056: public void testDefault() throws Exception {
057: executeTarget("testDefault");
058: }
059:
060: /**
061: * verify that "" binds us to the default compiler
062: */
063: public void testEmpty() throws Exception {
064: executeTarget("testEmpty");
065: }
066:
067: /**
068: * A unit test for JUnit
069: */
070: public void testRmic() throws Exception {
071: executeTarget("testRmic");
072: }
073:
074: /**
075: * A unit test for JUnit
076: */
077: public void testKaffe() throws Exception {
078: executeTarget("testKaffe");
079: }
080:
081: /**
082: * A unit test for JUnit
083: */
084: public void testWlrmic() throws Exception {
085: executeTarget("testWlrmic");
086: }
087:
088: /**
089: * test the forking compiler
090: */
091: public void NotestForking() throws Exception {
092: executeTarget("testForking");
093: }
094:
095: /**
096: * test the forking compiler
097: */
098: public void testForkingAntClasspath() throws Exception {
099: executeTarget("testForkingAntClasspath");
100: }
101:
102: /**
103: * test the forking compiler
104: */
105: public void testAntClasspath() throws Exception {
106: executeTarget("testAntClasspath");
107: }
108:
109: /**
110: * A unit test for JUnit
111: */
112: public void testBadName() throws Exception {
113: expectBuildExceptionContaining("testBadName",
114: "compiler not known",
115: RmicAdapterFactory.ERROR_UNKNOWN_COMPILER);
116: }
117:
118: /**
119: * load an adapter by name
120: */
121: public void testExplicitClass() throws Exception {
122: executeTarget("testExplicitClass");
123: }
124:
125: /**
126: * A unit test for JUnit
127: */
128: public void testWrongClass() throws Exception {
129: expectBuildExceptionContaining("testWrongClass",
130: "class not an RMIC adapter",
131: RmicAdapterFactory.ERROR_NOT_RMIC_ADAPTER);
132: }
133:
134: /**
135: * A unit test for JUnit
136: */
137: public void testDefaultBadClass() throws Exception {
138: expectBuildExceptionContaining("testDefaultBadClass",
139: "expected the class to fail", Rmic.ERROR_RMIC_FAILED);
140: //dont look for much text here as it is vendor and version dependent
141: assertLogContaining("unimplemented.class");
142: }
143:
144: /**
145: * A unit test for JUnit
146: */
147: public void testMagicProperty() throws Exception {
148: expectBuildExceptionContaining("testMagicProperty",
149: "magic property not working",
150: RmicAdapterFactory.ERROR_UNKNOWN_COMPILER);
151: }
152:
153: /**
154: * A unit test for JUnit
155: */
156: public void testMagicPropertyOverridesEmptyString()
157: throws Exception {
158: expectBuildExceptionContaining(
159: "testMagicPropertyOverridesEmptyString",
160: "magic property not working",
161: RmicAdapterFactory.ERROR_UNKNOWN_COMPILER);
162: }
163:
164: /**
165: *
166: */
167: public void testMagicPropertyIsEmptyString() throws Exception {
168: executeTarget("testMagicPropertyIsEmptyString");
169: }
170:
171: public void NotestFailingAdapter() throws Exception {
172: expectBuildExceptionContaining("testFailingAdapter",
173: "expected failures to propagate",
174: Rmic.ERROR_RMIC_FAILED);
175: }
176:
177: /**
178: * test that version 1.1 stubs are good
179: * @throws Exception
180: */
181: public void testVersion11() throws Exception {
182: executeTarget("testVersion11");
183: }
184:
185: /**
186: * test that version 1.2 stubs are good
187: *
188: * @throws Exception
189: */
190: public void testVersion12() throws Exception {
191: executeTarget("testVersion12");
192: }
193:
194: /**
195: * test that version compat stubs are good
196: *
197: * @throws Exception
198: */
199: public void testVersionCompat() throws Exception {
200: executeTarget("testVersionCompat");
201: }
202:
203: /**
204: * test that passes -Xnew to sun's rmic.
205: *
206: * @throws Exception
207: */
208: public void testXnew() throws Exception {
209: executeTarget("testXnew");
210: }
211:
212: /**
213: * test that passes -Xnew to sun's rmic running in a different VM.
214: *
215: * @throws Exception
216: */
217: public void testXnewForked() throws Exception {
218: executeTarget("testXnewForked");
219: }
220:
221: /**
222: * test that runs the new xnew compiler adapter.
223: *
224: * @throws Exception
225: */
226: public void testXnewCompiler() throws Exception {
227: executeTarget("testXnewCompiler");
228: }
229:
230: /**
231: * test that verifies that IDL compiles.
232: *
233: * @throws Exception
234: */
235: public void testIDL() throws Exception {
236: executeTarget("testIDL");
237: }
238:
239: /**
240: * test that verifies that IIOP compiles.
241: *
242: * @throws Exception
243: */
244: public void testIIOP() throws Exception {
245: executeTarget("testIIOP");
246: }
247:
248: /**
249: * this little bunny verifies that we can load stuff, and that
250: * a failure to execute is turned into a fault
251: */
252: public static class FailingRmicAdapter extends DefaultRmicAdapter {
253: public static final String LOG_MESSAGE = "hello from FailingRmicAdapter";
254:
255: /**
256: * Executes the task.
257: *
258: * @return false -always
259: */
260: public boolean execute() throws BuildException {
261: getRmic().log(LOG_MESSAGE);
262: return false;
263: }
264: }
265: }
|