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: package org.apache.tools.ant.taskdefs;
019:
020: import org.apache.tools.ant.taskdefs.condition.Os;
021: import org.apache.tools.ant.util.JavaEnvUtils;
022: import org.apache.tools.ant.BuildFileTest;
023:
024: /**
025: * Tests <bm:manifestclasspath>.
026: */
027: public class ManifestClassPathTest extends BuildFileTest {
028:
029: public void setUp() {
030: configureProject("src/etc/testcases/taskdefs/manifestclasspath.xml");
031: }
032:
033: public void testBadDirectory() {
034: expectBuildExceptionContaining("test-bad-directory",
035: "bad-jar-dir", "Jar's directory not found:");
036: assertPropertyUnset("jar.classpath");
037: }
038:
039: public void testBadNoProperty() {
040: expectBuildExceptionContaining("test-bad-no-property",
041: "no-property", "Missing 'property' attribute!");
042: assertPropertyUnset("jar.classpath");
043: }
044:
045: public void testBadPropertyExists() {
046: expectBuildExceptionContaining("test-bad-property-exists",
047: "property-exits",
048: "Property 'jar.classpath' already set!");
049: assertPropertyEquals("jar.classpath", "exists");
050: }
051:
052: public void testBadNoJarfile() {
053: expectBuildExceptionContaining("test-bad-no-jarfile",
054: "no-jarfile", "Missing 'jarfile' attribute!");
055: assertPropertyUnset("jar.classpath");
056: }
057:
058: public void testBadNoClassPath() {
059: expectBuildExceptionContaining("test-bad-no-classpath",
060: "no-classpath", "Missing nested <classpath>!");
061: assertPropertyUnset("jar.classpath");
062: }
063:
064: public void testParentLevel1() {
065: executeTarget("test-parent-level1");
066:
067: assertPropertyEquals("jar.classpath", "dsp-core/ "
068: + "dsp-pres/ " + "dsp-void/ "
069: + "../generated/dsp-core/ " + "../generated/dsp-pres/ "
070: + "../generated/dsp-void/ " + "../resources/dsp-core/ "
071: + "../resources/dsp-pres/ " + "../resources/dsp-void/");
072: }
073:
074: public void testParentLevel2() {
075: executeTarget("test-parent-level2");
076:
077: assertPropertyEquals("jar.classpath", "../dsp-core/ "
078: + "../dsp-pres/ " + "../dsp-void/ "
079: + "../../generated/dsp-core/ "
080: + "../../generated/dsp-pres/ "
081: + "../../generated/dsp-void/ "
082: + "../../resources/dsp-core/ "
083: + "../../resources/dsp-pres/ "
084: + "../../resources/dsp-void/");
085: }
086:
087: public void testParentLevel2TooDeep() {
088: expectBuildExceptionContaining("test-parent-level2-too-deep",
089: "nopath", "No suitable relative path from ");
090: assertPropertyUnset("jar.classpath");
091: }
092:
093: public void testPseudoTahoeRefid() {
094: executeTarget("test-pseudo-tahoe-refid");
095:
096: assertPropertyEquals("jar.classpath", "classes/dsp-core/ "
097: + "classes/dsp-pres/ " + "classes/dsp-void/ "
098: + "generated/dsp-core/ " + "resources/dsp-core/ "
099: + "resources/dsp-pres/");
100: }
101:
102: public void testPseudoTahoeNested() {
103: executeTarget("test-pseudo-tahoe-nested");
104:
105: assertPropertyEquals("jar.classpath", "classes/dsp-core/ "
106: + "classes/dsp-pres/ " + "classes/dsp-void/ "
107: + "generated/dsp-core/ " + "resources/dsp-core/ "
108: + "resources/dsp-pres/");
109: }
110:
111: public void testParentLevel2WithJars() {
112: executeTarget("test-parent-level2-with-jars");
113:
114: assertPropertyEquals("jar.classpath",
115: "../../lib/acme-core.jar " + "../../lib/acme-pres.jar "
116: + "../dsp-core/ " + "../dsp-pres/ "
117: + "../dsp-void/ "
118: + "../../generated/dsp-core/ "
119: + "../../generated/dsp-pres/ "
120: + "../../generated/dsp-void/ "
121: + "../../resources/dsp-core/ "
122: + "../../resources/dsp-pres/ "
123: + "../../resources/dsp-void/");
124: }
125:
126: public void testInternationalGerman() {
127: if (!JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_1_4)) {
128: System.out
129: .println("Test with international characters skipped under pre 1.4 jvm.");
130: return;
131: }
132: executeTarget("international-german");
133: expectLogContaining("run-two-jars", "beta alpha");
134:
135: }
136:
137: public void testInternationalHebrew() {
138: if (!JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_1_4)) {
139: System.out
140: .println("Test with international characters skipped under pre 1.4 jvm.");
141: return;
142: }
143: if (!Os.isFamily("windows")) {
144: executeTarget("international-hebrew");
145: expectLogContaining("run-two-jars", "beta alpha");
146: } else {
147: System.out
148: .println("Test with hebrew path not attempted under Windows");
149: }
150:
151: }
152:
153: } // END class ManifestClassPathTest
|