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.

DirnameTest.java 2.0 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * Copyright 2002,2004 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 org.apache.tools.ant.BuildFileTest;
  20. import org.apache.tools.ant.taskdefs.condition.Os;
  21. /**
  22. */
  23. public class DirnameTest extends BuildFileTest {
  24. public DirnameTest(String name) {
  25. super(name);
  26. }
  27. public void setUp() {
  28. configureProject("src/etc/testcases/taskdefs/dirname.xml");
  29. }
  30. public void test1() {
  31. expectBuildException("test1", "required attribute missing");
  32. }
  33. public void test2() {
  34. expectBuildException("test2", "required attribute missing");
  35. }
  36. public void test3() {
  37. expectBuildException("test3", "required attribute missing");
  38. }
  39. public void test4() {
  40. if (Os.isFamily("netware") || Os.isFamily("dos")) {
  41. return;
  42. }
  43. executeTarget("test4");
  44. String filesep = System.getProperty("file.separator");
  45. String expected = filesep + "usr" + filesep + "local";
  46. String checkprop = project.getProperty("local.dir");
  47. if (!checkprop.equals(expected)) {
  48. fail("dirname failed");
  49. }
  50. }
  51. public void test5() {
  52. executeTarget("test5");
  53. String expected = project.getProperty("basedir");
  54. String checkprop = project.getProperty("base.dir");
  55. if (!checkprop.equals(expected)) {
  56. fail("dirname failed");
  57. }
  58. }
  59. }