Browse Source

Move assertion statement inside try block and make the testcase pass on Windows environments with dubious java.home

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@272301 13f79535-47bb-0310-9956-ffa450edef68
master
Magesh Umasankar 23 years ago
parent
commit
6638f2ac2b
1 changed files with 12 additions and 12 deletions
  1. +12
    -12
      src/testcases/org/apache/tools/ant/util/JavaEnvUtilsTest.java

+ 12
- 12
src/testcases/org/apache/tools/ant/util/JavaEnvUtilsTest.java View File

@@ -82,7 +82,7 @@ public class JavaEnvUtilsTest extends TestCase {
public void testGetExecutableWindows() { public void testGetExecutableWindows() {
if (Os.isFamily("windows")) { if (Os.isFamily("windows")) {
FileUtils fileUtils = FileUtils.newFileUtils(); FileUtils fileUtils = FileUtils.newFileUtils();
String javaHome =
String javaHome =
fileUtils.normalize(System.getProperty("java.home")) fileUtils.normalize(System.getProperty("java.home"))
.getAbsolutePath(); .getAbsolutePath();


@@ -96,16 +96,16 @@ public class JavaEnvUtilsTest extends TestCase {
// java.home is bogus // java.home is bogus
assertEquals("java.exe", j); assertEquals("java.exe", j);
} }
j = JavaEnvUtils.getJdkExecutable("javac"); j = JavaEnvUtils.getJdkExecutable("javac");
assertTrue(j.endsWith(".exe")); assertTrue(j.endsWith(".exe"));
assertTrue(j+" is absolute", (new File(j)).isAbsolute());
try { try {
String javaHomeParent =
assertTrue(j+" is absolute", (new File(j)).isAbsolute());
String javaHomeParent =
fileUtils.normalize(javaHome+"/..").getAbsolutePath(); fileUtils.normalize(javaHome+"/..").getAbsolutePath();
assertTrue(j+" is normalized and in the JDK dir", assertTrue(j+" is normalized and in the JDK dir",
j.startsWith(javaHomeParent)); j.startsWith(javaHomeParent));
if (JavaEnvUtils.getJavaVersion() == JavaEnvUtils.JAVA_1_0 || if (JavaEnvUtils.getJavaVersion() == JavaEnvUtils.JAVA_1_0 ||
JavaEnvUtils.getJavaVersion() == JavaEnvUtils.JAVA_1_1) { JavaEnvUtils.getJavaVersion() == JavaEnvUtils.JAVA_1_1) {
assertTrue(j+" is normalized and in the JRE dir", assertTrue(j+" is normalized and in the JRE dir",
@@ -114,12 +114,12 @@ public class JavaEnvUtilsTest extends TestCase {
assertTrue(j+" is normalized and not in the JRE dir", assertTrue(j+" is normalized and not in the JRE dir",
!j.startsWith(javaHome)); !j.startsWith(javaHome));
} }
} catch (AssertionFailedError e) { } catch (AssertionFailedError e) {
// java.home is bogus // java.home is bogus
assertEquals("javac.exe", j); assertEquals("javac.exe", j);
} }
assertEquals("foo.exe", JavaEnvUtils.getJreExecutable("foo")); assertEquals("foo.exe", JavaEnvUtils.getJreExecutable("foo"));
assertEquals("foo.exe", JavaEnvUtils.getJdkExecutable("foo")); assertEquals("foo.exe", JavaEnvUtils.getJdkExecutable("foo"));
} }
@@ -128,7 +128,7 @@ public class JavaEnvUtilsTest extends TestCase {
public void testGetExecutableMostPlatforms() { public void testGetExecutableMostPlatforms() {
if (!Os.isName("netware") && !Os.isFamily("windows")) { if (!Os.isName("netware") && !Os.isFamily("windows")) {
FileUtils fileUtils = FileUtils.newFileUtils(); FileUtils fileUtils = FileUtils.newFileUtils();
String javaHome =
String javaHome =
fileUtils.normalize(System.getProperty("java.home")) fileUtils.normalize(System.getProperty("java.home"))
.getAbsolutePath(); .getAbsolutePath();


@@ -149,7 +149,7 @@ public class JavaEnvUtilsTest extends TestCase {
} }
assertTrue(j+" is absolute", (new File(j)).isAbsolute()); assertTrue(j+" is absolute", (new File(j)).isAbsolute());


String javaHomeParent =
String javaHomeParent =
fileUtils.normalize(javaHome+"/..").getAbsolutePath(); fileUtils.normalize(javaHome+"/..").getAbsolutePath();
assertTrue(j+" is normalized and in the JDK dir", assertTrue(j+" is normalized and in the JDK dir",
j.startsWith(javaHomeParent)); j.startsWith(javaHomeParent));
@@ -163,12 +163,12 @@ public class JavaEnvUtilsTest extends TestCase {
!j.startsWith(javaHome)); !j.startsWith(javaHome));
} }


assertEquals("foo"+extension,
assertEquals("foo"+extension,
JavaEnvUtils.getJreExecutable("foo")); JavaEnvUtils.getJreExecutable("foo"));
assertEquals("foo"+extension,
assertEquals("foo"+extension,
JavaEnvUtils.getJdkExecutable("foo")); JavaEnvUtils.getJdkExecutable("foo"));
} }
} }


} }

Loading…
Cancel
Save