You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

ManifestClassPathTest.java 6.1 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /*
  2. * Copyright 2000-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. package org.apache.tools.ant.taskdefs;
  18. import java.io.File;
  19. import java.util.Map;
  20. import java.util.Properties;
  21. import org.apache.tools.ant.BuildFileTest;
  22. /**
  23. * Tests <bm:manifestclasspath>.
  24. */
  25. public class ManifestClassPathTest
  26. extends BuildFileTest {
  27. public void setUp() {
  28. configureProject("src/etc/testcases/taskdefs/manifestclasspath.xml");
  29. }
  30. public void testBadDirectory() {
  31. expectBuildExceptionContaining("test-bad-directory", "bad-jar-dir",
  32. "Jar's directory not found:");
  33. assertPropertyUnset("jar.classpath");
  34. }
  35. public void testBadNoProperty() {
  36. expectBuildExceptionContaining("test-bad-no-property", "no-property",
  37. "Missing 'property' attribute!");
  38. assertPropertyUnset("jar.classpath");
  39. }
  40. public void testBadPropertyExists() {
  41. expectBuildExceptionContaining("test-bad-property-exists",
  42. "property-exits", "Property 'jar.classpath' already set!");
  43. assertPropertyEquals("jar.classpath", "exists");
  44. }
  45. public void testBadNoJarfile() {
  46. expectBuildExceptionContaining("test-bad-no-jarfile", "no-jarfile",
  47. "Missing 'jarfile' attribute!");
  48. assertPropertyUnset("jar.classpath");
  49. }
  50. public void testBadNoClassPath() {
  51. expectBuildExceptionContaining("test-bad-no-classpath", "no-classpath",
  52. "Missing nested <classpath>!");
  53. assertPropertyUnset("jar.classpath");
  54. }
  55. public void testParentLevel1() {
  56. executeTarget("test-parent-level1");
  57. assertPropertyEquals("jar.classpath", "dsp-core/ " +
  58. "dsp-pres/ " +
  59. "dsp-void/ " +
  60. "../generated/dsp-core/ " +
  61. "../generated/dsp-pres/ " +
  62. "../generated/dsp-void/ " +
  63. "../resources/dsp-core/ " +
  64. "../resources/dsp-pres/ " +
  65. "../resources/dsp-void/");
  66. }
  67. public void testParentLevel2() {
  68. executeTarget("test-parent-level2");
  69. assertPropertyEquals("jar.classpath", "../dsp-core/ " +
  70. "../dsp-pres/ " +
  71. "../dsp-void/ " +
  72. "../../generated/dsp-core/ " +
  73. "../../generated/dsp-pres/ " +
  74. "../../generated/dsp-void/ " +
  75. "../../resources/dsp-core/ " +
  76. "../../resources/dsp-pres/ " +
  77. "../../resources/dsp-void/");
  78. }
  79. public void testParentLevel2TooDeep() {
  80. expectBuildExceptionContaining("test-parent-level2-too-deep", "nopath",
  81. "No suitable relative path from ");
  82. assertPropertyUnset("jar.classpath");
  83. }
  84. public void testPseudoTahoeRefid() {
  85. executeTarget("test-pseudo-tahoe-refid");
  86. assertPropertyEquals("jar.classpath", "classes/dsp-core/ " +
  87. "classes/dsp-pres/ " +
  88. "classes/dsp-void/ " +
  89. "generated/dsp-core/ " +
  90. "resources/dsp-core/ " +
  91. "resources/dsp-pres/");
  92. }
  93. public void testPseudoTahoeNested() {
  94. executeTarget("test-pseudo-tahoe-nested");
  95. assertPropertyEquals("jar.classpath", "classes/dsp-core/ " +
  96. "classes/dsp-pres/ " +
  97. "classes/dsp-void/ " +
  98. "generated/dsp-core/ " +
  99. "resources/dsp-core/ " +
  100. "resources/dsp-pres/");
  101. }
  102. public void testParentLevel2WithJars() {
  103. executeTarget("test-parent-level2-with-jars");
  104. assertPropertyEquals("jar.classpath", "../../lib/acme-core.jar " +
  105. "../../lib/acme-pres.jar " +
  106. "../dsp-core/ " +
  107. "../dsp-pres/ " +
  108. "../dsp-void/ " +
  109. "../../generated/dsp-core/ " +
  110. "../../generated/dsp-pres/ " +
  111. "../../generated/dsp-void/ " +
  112. "../../resources/dsp-core/ " +
  113. "../../resources/dsp-pres/ " +
  114. "../../resources/dsp-void/");
  115. }
  116. } // END class ManifestClassPathTest